From: Andrew Cooper Subject: [PATCH 32/32] block-vvfat: fix resource leaks in read_directory() Date: Wed, 22 Apr 2015 16:08:09 +0100 Message-ID: <1429715289-4954-32-git-send-email-andrew.cooper3@citrix.com> References: <1429715235-4759-1-git-send-email-andrew.cooper3@citrix.com> <1429715289-4954-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1429715289-4954-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel List-Id: xen-devel@lists.xenproject.org From: Yunlei Ding Signed-off-by: Yunlei Ding Coverity-IDs: 1055920 1055921 Reviewed-by: Andrew Cooper --- block-vvfat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block-vvfat.c b/block-vvfat.c index 6cd57a2..ff5c8bf 100644 --- a/block-vvfat.c +++ b/block-vvfat.c @@ -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); -- 1.7.10.4