Patchwork [3/7] vvfat: fix a file descriptor leak

login
register
mail settings
Submitter Blue Swirl
Date Jan. 8, 2011, 6:24 p.m.
Message ID <AANLkTi=ZZAyK08zAbJmQNr3CkYjO5nQu-RrcdrO4Sxnz@mail.gmail.com>
Download mbox | patch
Permalink /patch/77975/
State New
Headers show

Comments

Blue Swirl - Jan. 8, 2011, 6:24 p.m.
Fix a file descriptor leak, reported by cppcheck:
[/src/qemu/block/vvfat.c:759]: (error) Resource leak: dir

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 block/vvfat.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

 	direntry->size=cpu_to_le32(S_ISDIR(st.st_mode)?0:st.st_size);

Patch

diff --git a/block/vvfat.c b/block/vvfat.c
index 26dd474..fe568fe 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -756,6 +756,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;
         }