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

Commit 83ec65e1 authored by Colin Cross's avatar Colin Cross
Browse files

Fix allocation count

The realloc case in continueWrite should not increment the counter,
the pointer passed to realloc is guaranteed to be non-NULL so the total
number of allocations will not have changed.

When realloc is called in restartWrite mData has not been checked
against NULL, increment the counter if it was NULL.

Bug: 26086286
Change-Id: I4c8af450cca1868b91793c0c5f0d8c4b4b5badbe
parent 18ff6557
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -1963,6 +1963,9 @@ status_t Parcel::restartWrite(size_t desired)
        pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
        pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
        gParcelGlobalAllocSize += desired;
        gParcelGlobalAllocSize += desired;
        gParcelGlobalAllocSize -= mDataCapacity;
        gParcelGlobalAllocSize -= mDataCapacity;
        if (!mData) {
            gParcelGlobalAllocCount++;
        }
        pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
        pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
        mData = data;
        mData = data;
        mDataCapacity = desired;
        mDataCapacity = desired;
@@ -2094,7 +2097,6 @@ status_t Parcel::continueWrite(size_t desired)
                pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
                pthread_mutex_lock(&gParcelGlobalAllocSizeLock);
                gParcelGlobalAllocSize += desired;
                gParcelGlobalAllocSize += desired;
                gParcelGlobalAllocSize -= mDataCapacity;
                gParcelGlobalAllocSize -= mDataCapacity;
                gParcelGlobalAllocCount++;
                pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
                pthread_mutex_unlock(&gParcelGlobalAllocSizeLock);
                mData = data;
                mData = data;
                mDataCapacity = desired;
                mDataCapacity = desired;