From: Theodore Ts'o Date: Sun, 5 Jan 2014 06:12:48 +0000 (-0500) Subject: libss: fix potential memory leak on realloc() failure X-Git-Tag: v1.42.10~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=191a03ac5f;p=thirdparty%2Fe2fsprogs.git libss: fix potential memory leak on realloc() failure Addresses-Coverity-ID: #295143 Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ss/invocation.c b/lib/ss/invocation.c index 61c2e3508..924427ac0 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; + register ss_data **table, **rt; *code_ptr = 0; table = _ss_table; @@ -42,10 +42,10 @@ int ss_create_invocation(const char *subsystem_name, const char *version_string, for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++) ; - table = (ss_data **) realloc((char *)table, - ((unsigned)sci_idx+2)*size); - if (table == NULL) { - *code_ptr = errno; + rt = (ss_data **) realloc((char *)table, ((unsigned)sci_idx+2)*size); + if (rt == NULL) { + *code_ptr = ENOMEM; + free(table); return 0; } table[sci_idx+1] = (ss_data *) NULL;