Blob Blame History Raw
rpmemd: fix potential memory leak

BZ: 

commit fbef3efa8c874ec71cb69455603a03ba9023641f
Author: Jeff Moyer <jmoyer@redhat.com>
Date:   Thu Oct 19 17:20:12 2017 -0400

    rpmemd: fix potential memory leak
    
    If realloc fails, the original buffer is leaked.  Fix it.
    
    Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

diff --git a/src/tools/rpmemd/rpmemd_config.c b/src/tools/rpmemd/rpmemd_config.c
index 17720b6..7cd4505 100644
--- a/src/tools/rpmemd/rpmemd_config.c
+++ b/src/tools/rpmemd/rpmemd_config.c
@@ -389,12 +389,13 @@ parse_config_file(const char *filename, struct rpmemd_config *config,
 			goto error;
 
 		if (line_max_increased) {
-			line_copy = (char *)realloc(line_copy,
+			char *new = (char *)realloc(line_copy,
 				sizeof(char) * line_max);
-			if (line_copy == NULL) {
+			if (new == NULL) {
 				RPMEMD_LOG(ERR, "!malloc");
-				goto error_malloc_line_copy;
+				goto error;
 			}
+			line_copy = new;
 			line_max_increased = 0;
 		}