From 5e5c6bb3138edb73a15666fe76780b160f2056e2 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Fri, 16 Dec 2011 20:22:34 -0500 Subject: [PATCH] bug 709330 - AboutHomeContent.getRecommendedAddonsStream() resource leak because ZipFile was not closed r=mfinkle --- mobile/android/base/AboutHomeContent.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mobile/android/base/AboutHomeContent.java b/mobile/android/base/AboutHomeContent.java index f064d1ebd371..ff32eb06a047 100644 --- a/mobile/android/base/AboutHomeContent.java +++ b/mobile/android/base/AboutHomeContent.java @@ -236,13 +236,19 @@ public class AboutHomeContent extends ScrollView { if (is != null) return is; File applicationPackage = new File(activity.getApplication().getPackageResourcePath()); - ZipFile zip = new ZipFile(applicationPackage); - if (zip == null) - return null; - ZipEntry fileEntry = zip.getEntry("recommended-addons.json"); - if (fileEntry == null) - return null; - return zip.getInputStream(fileEntry); + ZipFile zip = null; + try { + zip = new ZipFile(applicationPackage); + if (zip == null) + return null; + ZipEntry fileEntry = zip.getEntry("recommended-addons.json"); + if (fileEntry == null) + return null; + return zip.getInputStream(fileEntry); + } finally { + if (zip != null) + zip.close(); + } } void readRecommendedAddons(final Activity activity) {