From a9ab6078c8e6d23d539569f4dce0f86a4492a41b Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 23 Aug 2020 13:06:39 +0200 Subject: [PATCH] Fix compiler warnings --- src/utils/StringTools.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/StringTools.cpp b/src/utils/StringTools.cpp index 2483972..c60227e 100644 --- a/src/utils/StringTools.cpp +++ b/src/utils/StringTools.cpp @@ -270,20 +270,22 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) { if (len_rep == 0) { return NULL; } // empty rep causes infinite loop during count - if (!with) - with = ""; + if (!with) { + with = (char *) ""; + } len_with = strlen(with); // count the number of replacements needed ins = orig; - for (count = 0; tmp = strstr(ins, rep); ++count) { + for (count = 0; (tmp = strstr(ins, rep)); ++count) { ins = tmp + len_rep; } tmp = result = (char *) malloc(strlen(orig) + (len_with - len_rep) * count + 1); - if (!result) + if (!result) { return NULL; + } // first time through the loop, all the variable are set correctly // from here on,