Cleanup coverity scan issues
If realloc fails, then buffer will be leaked, this change frees up the buffer.
@@ -70,10 +70,13 @@ get_cmd_line_args (pid_t pid)
if (allocated == used)
{
allocated += 512;
- buffer = realloc (buffer, allocated);
- if (buffer == NULL)
+ char *tmp = realloc (buffer, allocated);
+ if (buffer == NULL) {
+ free(buffer);
return NULL;
}
+ buffer=tmp;
+ }
}
close (fd);
