Fix leak on error path
authorCristian Rodríguez <crrodriguez@opensuse.org>
Fri, 23 Dec 2011 05:06:56 +0000 (03:06 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Fri, 23 Dec 2011 05:08:57 +0000 (03:08 -0200)
libkmod/libkmod-index.c

index 2f6e799..9a0dd2a 100644 (file)
@@ -342,8 +342,10 @@ struct index_file *index_file_open(const char *filename)
        errno = EINVAL;
 
        magic = read_long(file);
-       if (magic != INDEX_MAGIC)
+       if (magic != INDEX_MAGIC) {
+               fclose(file);
                return NULL;
+       }
 
        version = read_long(file);
        if (version >> 16 != INDEX_VERSION_MAJOR)