]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libss: fix potential memory leak on realloc() failure
authorTheodore Ts'o <tytso@google.com>
Sun, 5 Jan 2014 06:12:48 +0000 (01:12 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 6 Jan 2014 03:58:16 +0000 (22:58 -0500)
Addresses-Coverity-ID: #295143

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ss/invocation.c

index 61c2e3508ec198f9d477dc786a433dedec6160d4..924427ac0c160c5f6dd5871bd0bbf815cbeab662 100644 (file)
@@ -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;