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

Commit 16a1f52f authored by Uday Kiran Jandhyala's avatar Uday Kiran Jandhyala Committed by Gerrit - the friendly Code Review server
Browse files

Black Screen: Fix dlfree error when delet mZipInflater.

_CompressedAsset::close() and _CompressedAsset::getBuffer() may
delete mZipInflater object without mutex protection. This may cause
race condition during two thread try to delete mZipInflater object
at the same time. Fix this issue by adding auto local mutex lock in
_CompressedAsset::close() and _CompressedAsset::getBuffer().

CRs-Fixed: 822097

Change-Id: I7c8d2e308e196db54c6a91bc2d16545b331f87bc
parent 82bb9d95
Loading
Loading
Loading
Loading

include/androidfw/Asset.h

100644 → 100755
+2 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <utils/Errors.h>
#include <utils/FileMap.h>
#include <utils/String8.h>
#include <utils/threads.h>

namespace android {

@@ -272,7 +273,7 @@ class _CompressedAsset : public Asset {
public:
    _CompressedAsset(void);
    virtual ~_CompressedAsset(void);

    Mutex mCompressedAssetLock;
    /*
     * Use a piece of an already-open file.
     *

libs/androidfw/Asset.cpp

100644 → 100755
+2 −0
Original line number Diff line number Diff line
@@ -820,6 +820,7 @@ off64_t _CompressedAsset::seek(off64_t offset, int whence)
 */
void _CompressedAsset::close(void)
{
    AutoMutex _l(mCompressedAssetLock);
    if (mMap != NULL) {
        mMap->release();
        mMap = NULL;
@@ -845,6 +846,7 @@ void _CompressedAsset::close(void)
 */
const void* _CompressedAsset::getBuffer(bool)
{
    AutoMutex _l(mCompressedAssetLock);
    unsigned char* buf = NULL;

    if (mBuf != NULL)