diff options
author | Henrik Baard <henrik.baard@sonymobile.com> | 2014-06-18 13:34:01 +0200 |
---|---|---|
committer | Henrik Baard <henrik.baard@sonymobile.com> | 2014-06-23 14:03:46 +0200 |
commit | 5f7ce10c937abf7da6d547ae91bda495dfbc414d (patch) | |
tree | 5b3435aca8d2ec60519464a3a99b71dc5d969249 /libs/androidfw | |
parent | 1a3908e95926acd8add3858be571fe23fa9d047a (diff) | |
download | frameworks_base-5f7ce10c937abf7da6d547ae91bda495dfbc414d.zip frameworks_base-5f7ce10c937abf7da6d547ae91bda495dfbc414d.tar.gz frameworks_base-5f7ce10c937abf7da6d547ae91bda495dfbc414d.tar.bz2 |
Memory leak in parsePackage
The method parsePackage failes to delete some resources
in case of failures.
Added delete of "package" in the cases that was previously
missed.
Change-Id: I183e9ec5864c5ed18bb48410ab41317cb3d96bda
Diffstat (limited to 'libs/androidfw')
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 1ffe665..2c828c1 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -5405,23 +5405,33 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, return (mError=err); } + err = group->packages.add(package); + if (err < NO_ERROR) { + delete group; + delete package; + return (mError=err); + } + group->basePackage = package; + //printf("Adding new package id %d at index %d\n", id, idx); err = mPackageGroups.add(group); if (err < NO_ERROR) { + delete group; return (mError=err); } - group->basePackage = package; mPackageMap[id] = (uint8_t)idx; } else { group = mPackageGroups.itemAt(idx-1); if (group == NULL) { + delete package; return (mError=UNKNOWN_ERROR); } - } - err = group->packages.add(package); - if (err < NO_ERROR) { - return (mError=err); + err = group->packages.add(package); + if (err < NO_ERROR) { + delete package; + return (mError=err); + } } } else { LOG_ALWAYS_FATAL("Package id out of range"); |