Cppcheck 1.90 dev reports following:
cli.c:117:4: error: Common realloc mistake: 'typestr' nulled but not freed upon failure [memleakOnRealloc]
typestr = realloc(typestr, maxlen);
^
Signed-off-by: Petr Štetiar <ynezz@true.cz>
maxlen = strlen(s->type) + 1 + 2 + 10;
if (!typestr) {
typestr = malloc(maxlen);
+ if (!typestr)
+ return NULL;
} else {
- typestr = realloc(typestr, maxlen);
+ void *p = realloc(typestr, maxlen);
+ if (!p) {
+ free(typestr);
+ return NULL;
+ }
+
+ typestr = p;
}
if (typestr)