From 0abb757425af993ba9acae7602d739ef83963a7f Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 15 Jan 2019 14:13:42 -0500 Subject: Cleanup coverity scan issues If realloc fails, then buffer will be leaked, this change frees up the buffer. Signed-off-by: Daniel J Walsh --- pkg/rootless/rootless_linux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'pkg/rootless/rootless_linux.c') 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); -- cgit v1.2.3-54-g00ecf