1 From 8cd407e5c0fb8390c7a9cfe2b4833d3fd88f3f08 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= <marten.kongstad@sonymobile.com>
3 Date: Thu, 2 Jun 2016 09:34:36 +0200
4 Subject: [PATCH 06/52] OMS7-N: Fix memory leak during idmap creation [6/11]
6 Plug a memory leak in AssetManager::createIdmap.
8 Change-Id: Ieed805c596df931e2167ebb47c1b2907d6bf67f4
10 libs/androidfw/AssetManager.cpp | 38 +++++++++++++++++++++++++-------------
11 1 file changed, 25 insertions(+), 13 deletions(-)
13 diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
14 index 5eae1459444..8669f243fee 100644
15 --- a/libs/androidfw/AssetManager.cpp
16 +++ b/libs/androidfw/AssetManager.cpp
17 @@ -292,22 +292,34 @@ bool AssetManager::createIdmap(const char* targetApkPath, const char* overlayApk
20 const String8 paths[2] = { String8(targetApkPath), String8(overlayApkPath) };
23 - for (int i = 0; i < 2; ++i) {
25 - ap.type = kFileTypeRegular;
27 - Asset* ass = openNonAssetInPathLocked("resources.arsc", Asset::ACCESS_BUFFER, ap);
29 - ALOGW("failed to find resources.arsc in %s\n", ap.path.string());
31 + Asset* assets[2] = {NULL, NULL};
36 + for (int i = 0; i < 2; ++i) {
38 + ap.type = kFileTypeRegular;
40 + assets[i] = openNonAssetInPathLocked("resources.arsc",
41 + Asset::ACCESS_BUFFER, ap);
42 + if (assets[i] == NULL) {
43 + ALOGW("failed to find resources.arsc in %s\n", ap.path.string());
46 + if (tables[i].add(assets[i]) != NO_ERROR) {
47 + ALOGW("failed to add %s to resource table", paths[i].string());
52 + ret = tables[0].createIdmap(tables[1], targetCrc, overlayCrc,
53 + targetApkPath, overlayApkPath, (void**)outData, outSize) == NO_ERROR;
56 - return tables[0].createIdmap(tables[1], targetCrc, overlayCrc,
57 - targetApkPath, overlayApkPath, (void**)outData, outSize) == NO_ERROR;
64 bool AssetManager::addDefaultAssets()