Whamcloud - gitweb
[COVERITY] Fix memory leak in profile library
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 21 Mar 2007 20:14:37 +0000 (16:14 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 21 Mar 2007 20:14:37 +0000 (16:14 -0400)
The profile must be freed early if the subsequent memory allocation
fails for 'expanded_filename'.

Coverity ID: 14: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/ChangeLog
e2fsck/profile.c

index 4e0ba88..8d5e491 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-21  Theodore Tso  <tytso@mit.edu>
+
+       * profile.c (profile_open_file): Fix memory leak if malloc() fails
+               while setting up the profile data structure.
+
 2007-03-19  Theodore Tso  <tytso@mit.edu>
 
        * pass3.c (check_directory): Add error check in case
index 8030680..3352a22 100644 (file)
@@ -417,8 +417,10 @@ errcode_t profile_open_file(const char * filespec,
                        len += strlen(home_env);
        }
        expanded_filename = malloc(len);
-       if (expanded_filename == 0)
+       if (expanded_filename == 0) {
+           profile_free_file(prf);     
            return errno;
+       }
        if (home_env) {
            strcpy(expanded_filename, home_env);
            strcat(expanded_filename, filespec+1);