]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: free field list when failing out of fuzz
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 18 Aug 2017 17:00:01 +0000 (12:00 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 18 Aug 2017 17:00:01 +0000 (12:00 -0500)
Fix a missed opportunity to free the field list when we fail out of the
fuzz command by refactoring the error clauses to use a common cleanup
clause.

Fixes-coverity-id: 1416141
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/fuzz.c

index a9b1577030b270dae9f1e3a3041acd41f0e56424..76dbf940a9a7a41201527fe7b5964f29a0040e7b 100644 (file)
--- a/db/fuzz.c
+++ b/db/fuzz.c
@@ -400,7 +400,7 @@ fuzz_struct(
                        break;
        if (fc->fn == NULL) {
                dbprintf(_("Unknown fuzz command '%s'.\n"), argv[1]);
-               return;
+               goto out_free;
        }
 
        /* if we're a root field type, go down 1 layer to get field list */
@@ -412,9 +412,8 @@ fuzz_struct(
 
        /* run down the field list and set offsets into the data */
        if (!flist_parse(fields, fl, iocur_top->data, 0)) {
-               flist_free(fl);
                dbprintf(_("parsing error\n"));
-               return;
+               goto out_free;
        }
 
        sfl = fl;
@@ -447,8 +446,7 @@ fuzz_struct(
        success = fc->fn(iocur_top->data, sfl->offset, bit_length);
        if (!success) {
                dbprintf(_("unable to fuzz field '%s'\n"), argv[0]);
-               flist_free(fl);
-               return;
+               goto out_free;
        }
 
        /* Write the fuzzed value back */
@@ -456,5 +454,6 @@ fuzz_struct(
 
        flist_print(fl);
        print_flist(fl);
+out_free:
        flist_free(fl);
 }