Whamcloud - gitweb
Set pointer to NULL after ext2fs_free
[tools/e2fsprogs.git] / lib / ext2fs / openfs.c
index 8035755..a1a3517 100644 (file)
@@ -450,10 +450,11 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
 
        return 0;
 cleanup:
-       if (flags & EXT2_FLAG_NOFREE_ON_ERROR)
-               *ret_fs = fs;
-       else
+       if (!(flags & EXT2_FLAG_NOFREE_ON_ERROR)) {
                ext2fs_free(fs);
+               fs = NULL;
+       }
+       *ret_fs = fs;
        return retval;
 }