From 6c8e5db9c15844393247fbd0444e4c7e6f725d13 Mon Sep 17 00:00:00 2001 From: Atul Aggarwal Date: Wed, 31 Aug 2011 16:30:33 +0100 Subject: [PATCH] Bug 679612 - Add fclose calls to every exit point in APKOpen.cpp to prevent resource leaks; r=mwu --- other-licenses/android/APKOpen.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/other-licenses/android/APKOpen.cpp b/other-licenses/android/APKOpen.cpp index c5f59db0074e..c85911920e31 100644 --- a/other-licenses/android/APKOpen.cpp +++ b/other-licenses/android/APKOpen.cpp @@ -291,6 +291,7 @@ extractFile(const char * path, const struct cdir_entry *entry, void * data) MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (buf == (void *)-1) { __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't mmap decompression buffer"); + close(fd); return; } @@ -510,10 +511,12 @@ static void * mozload(const char * path, void *zip, // we'd like to use fallocate here, but it doesn't exist currently? if (lseek(fd, lib_size - 1, SEEK_SET) == (off_t) - 1) { __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "seeking file failed"); + close(fd); return NULL; } if (write(fd, "", 1) != 1) { __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "writting one byte to the file failed"); + close(fd); return NULL; } skipLibCache = true;