Initial commit
[GitHub/Stricted/android_vendor_extra.git] / frameworks / base / 0006-OMS7-N-Fix-memory-leak-during-idmap-creation-6-11.patch
1 From a2ce720b5bfca010dc28ab9cd79e9a8d94f981b3 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/38] OMS7-N: Fix memory leak during idmap creation [6/11]
5
6 Plug a memory leak in AssetManager::createIdmap.
7
8 Change-Id: Ieed805c596df931e2167ebb47c1b2907d6bf67f4
9 ---
10 libs/androidfw/AssetManager.cpp | 38 +++++++++++++++++++++++++-------------
11 1 file changed, 25 insertions(+), 13 deletions(-)
12
13 diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
14 index 924b230..c501e8b 100644
15 --- a/libs/androidfw/AssetManager.cpp
16 +++ b/libs/androidfw/AssetManager.cpp
17 @@ -291,22 +291,34 @@ bool AssetManager::createIdmap(const char* targetApkPath, const char* overlayApk
18 {
19 AutoMutex _l(mLock);
20 const String8 paths[2] = { String8(targetApkPath), String8(overlayApkPath) };
21 - ResTable tables[2];
22 -
23 - for (int i = 0; i < 2; ++i) {
24 - asset_path ap;
25 - ap.type = kFileTypeRegular;
26 - ap.path = paths[i];
27 - Asset* ass = openNonAssetInPathLocked("resources.arsc", Asset::ACCESS_BUFFER, ap);
28 - if (ass == NULL) {
29 - ALOGW("failed to find resources.arsc in %s\n", ap.path.string());
30 - return false;
31 + Asset* assets[2] = {NULL, NULL};
32 + bool ret = false;
33 + {
34 + ResTable tables[2];
35 +
36 + for (int i = 0; i < 2; ++i) {
37 + asset_path ap;
38 + ap.type = kFileTypeRegular;
39 + ap.path = paths[i];
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());
44 + goto exit;
45 + }
46 + if (tables[i].add(assets[i]) != NO_ERROR) {
47 + ALOGW("failed to add %s to resource table", paths[i].string());
48 + goto exit;
49 + }
50 }
51 - tables[i].add(ass);
52 + ret = tables[0].createIdmap(tables[1], targetCrc, overlayCrc,
53 + targetApkPath, overlayApkPath, (void**)outData, outSize) == NO_ERROR;
54 }
55
56 - return tables[0].createIdmap(tables[1], targetCrc, overlayCrc,
57 - targetApkPath, overlayApkPath, (void**)outData, outSize) == NO_ERROR;
58 +exit:
59 + delete assets[0];
60 + delete assets[1];
61 + return ret;
62 }
63
64 bool AssetManager::addDefaultAssets()
65 --
66 2.9.3
67