Commit 2f0a4b3d authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Test realloc failure to make cppcheck happy

parent 99bc2377
Showing with 11 additions and 2 deletions
+11 -2
......@@ -68,7 +68,13 @@ char** String_split(const char* s, char sep, int* n) {
ctr++;
if (ctr == blocks) {
blocks += rate;
out = (char**) realloc(out, sizeof(char*) * blocks);
char** newOut = (char**) realloc(out, sizeof(char*) * blocks);
if (newOut) {
out = newOut;
} else {
blocks -= rate;
break;
}
}
s += size + 1;
}
......@@ -79,7 +85,10 @@ char** String_split(const char* s, char sep, int* n) {
out[ctr] = token;
ctr++;
}
out = realloc(out, sizeof(char*) * (ctr + 1));
char** newOut = realloc(out, sizeof(char*) * (ctr + 1));
if (newOut) {
out = newOut;
}
out[ctr] = NULL;
*n = ctr;
return out;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment