summaryrefslogtreecommitdiff
path: root/pkg/rootless/rootless_linux.c
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-01-15 14:13:42 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2019-01-15 17:09:15 -0500
commit0abb757425af993ba9acae7602d739ef83963a7f (patch)
treee629557c897d8b157685014923c08a5b855e32cc /pkg/rootless/rootless_linux.c
parent1b2f75298d98f59fac73a63599cdca3478bef835 (diff)
downloadpodman-0abb757425af993ba9acae7602d739ef83963a7f.tar.gz
podman-0abb757425af993ba9acae7602d739ef83963a7f.tar.bz2
podman-0abb757425af993ba9acae7602d739ef83963a7f.zip
Cleanup coverity scan issues
If realloc fails, then buffer will be leaked, this change frees up the buffer. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/rootless/rootless_linux.c')
-rw-r--r--pkg/rootless/rootless_linux.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c
index 1d28ff68d..279a03d3f 100644
--- a/pkg/rootless/rootless_linux.c
+++ b/pkg/rootless/rootless_linux.c
@@ -70,9 +70,12 @@ get_cmd_line_args (pid_t pid)
if (allocated == used)
{
allocated += 512;
- buffer = realloc (buffer, allocated);
- if (buffer == NULL)
- return NULL;
+ char *tmp = realloc (buffer, allocated);
+ if (buffer == NULL) {
+ free(buffer);
+ return NULL;
+ }
+ buffer=tmp;
}
}
close (fd);