]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/qemu-xen-traditional.git/commitdiff
block-vvfat: fix resource leaks in read_directory()
authorYunlei Ding <yunlei.ding@citrix.com>
Tue, 11 Mar 2014 10:19:23 +0000 (10:19 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 16 Oct 2015 15:52:07 +0000 (16:52 +0100)
Signed-off-by: Yunlei Ding <yunlei.ding@citrix.com>
Coverity-IDs: 1055920 1055921
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
block-vvfat.c

index 6cd57a2a6276bf7cb301f7b903b7a4baa0e69c4b..ff5c8bf577fc78444950c9260f5b813b1410e5fb 100644 (file)
@@ -760,6 +760,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
         if (st.st_size > 0x7fffffff) {
            fprintf(stderr, "File %s is larger than 2GB\n", buffer);
            free(buffer);
+            closedir(dir);
            return -2;
         }
        direntry->size=cpu_to_le32(S_ISDIR(st.st_mode)?0:st.st_size);
@@ -787,6 +788,8 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
            s->current_mapping->read_only =
                (st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)) == 0;
        }
+        else
+            qemu_free(buffer);
     }
     closedir(dir);