vvfat: fix a file descriptor leak

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>
This commit is contained in:
Blue Swirl 2011-01-12 19:48:58 +00:00
parent cedf9a6f45
commit 08089edcd2

View File

@ -756,6 +756,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
if (st.st_size > 0x7fffffff) { if (st.st_size > 0x7fffffff) {
fprintf(stderr, "File %s is larger than 2GB\n", buffer); fprintf(stderr, "File %s is larger than 2GB\n", buffer);
free(buffer); free(buffer);
closedir(dir);
return -2; return -2;
} }
direntry->size=cpu_to_le32(S_ISDIR(st.st_mode)?0:st.st_size); direntry->size=cpu_to_le32(S_ISDIR(st.st_mode)?0:st.st_size);