Fix thread race caused double free issue.
am: 5754b41c20
Change-Id: Ic9dd6e9c6d216753d997da99158816682d5464d1
This commit is contained in:
@@ -1893,6 +1893,7 @@ ZipFileRO* AssetManager::SharedZip::getZip()
|
|||||||
|
|
||||||
Asset* AssetManager::SharedZip::getResourceTableAsset()
|
Asset* AssetManager::SharedZip::getResourceTableAsset()
|
||||||
{
|
{
|
||||||
|
AutoMutex _l(gLock);
|
||||||
ALOGV("Getting from SharedZip %p resource asset %p\n", this, mResourceTableAsset);
|
ALOGV("Getting from SharedZip %p resource asset %p\n", this, mResourceTableAsset);
|
||||||
return mResourceTableAsset;
|
return mResourceTableAsset;
|
||||||
}
|
}
|
||||||
@@ -1902,10 +1903,10 @@ Asset* AssetManager::SharedZip::setResourceTableAsset(Asset* asset)
|
|||||||
{
|
{
|
||||||
AutoMutex _l(gLock);
|
AutoMutex _l(gLock);
|
||||||
if (mResourceTableAsset == NULL) {
|
if (mResourceTableAsset == NULL) {
|
||||||
mResourceTableAsset = asset;
|
|
||||||
// This is not thread safe the first time it is called, so
|
// This is not thread safe the first time it is called, so
|
||||||
// do it here with the global lock held.
|
// do it here with the global lock held.
|
||||||
asset->getBuffer(true);
|
asset->getBuffer(true);
|
||||||
|
mResourceTableAsset = asset;
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user