Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fc38626 authored by wangjing's avatar wangjing
Browse files

libandroidfw: Fatal exception of dlfree often causes the system crashed

When the function 'getBuffer' are called at the same time by the threads,
mZipInflater will be 'delete' twice if mZipInflater isn't NULL,
that is 'mZipInflater = NULL' has not be reached,
at this time it will cause system server crashed.

Add AutoMutex at the beginning of the function to avoid getBuffer to
be called at the same time.

CRs-Fixed: 812950
Change-Id: I283b43a01b97ae6a149749ff2186efda9df4dc42
parent e4d591e9
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ static Mutex gAssetLock;
static int32_t gCount = 0;
static Asset* gHead = NULL;
static Asset* gTail = NULL;
static Mutex sLock;

int32_t Asset::getGlobalCount()
{
@@ -846,7 +847,9 @@ void _CompressedAsset::close(void)
 */
const void* _CompressedAsset::getBuffer(bool)
{
    AutoMutex _l(mCompressedAssetLock);
    if (mBuf != NULL)
        return mBuf;
    AutoMutex _l(sLock);
    unsigned char* buf = NULL;

    if (mBuf != NULL)