From: Theodore Ts'o Date: Tue, 7 Jan 2014 03:20:38 +0000 (-0500) Subject: libss: fix potential memory leak on realloc() failure X-Git-Tag: v1.42.9.wc1~126 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=1d1f708e442c60ec9fa19a16ef251750cea1c1bb;p=tools%2Fe2fsprogs.git libss: fix potential memory leak on realloc() failure Commit 191a03ac5f was an incorrect fix for this issue. Fix it up. Addresses-Coverity-ID: #295143 Addresses-Coverity-ID: #1148451 Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ss/invocation.c b/lib/ss/invocation.c index 924427a..457e7a2 100644 --- a/lib/ss/invocation.c +++ b/lib/ss/invocation.c @@ -28,7 +28,7 @@ int ss_create_invocation(const char *subsystem_name, const char *version_string, { register int sci_idx; register ss_data *new_table; - register ss_data **table, **rt; + register ss_data **table; *code_ptr = 0; table = _ss_table; @@ -42,10 +42,11 @@ int ss_create_invocation(const char *subsystem_name, const char *version_string, for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++) ; - rt = (ss_data **) realloc((char *)table, ((unsigned)sci_idx+2)*size); - if (rt == NULL) { + table = (ss_data **) realloc((char *)table, + ((unsigned)sci_idx+2)*size); + if (table == NULL) { *code_ptr = ENOMEM; - free(table); + free(new_table); return 0; } table[sci_idx+1] = (ss_data *) NULL;