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

Commit 3f945fa5 authored by Ted Bonkenburg's avatar Ted Bonkenburg
Browse files

Read leftover parcel data when a parceled Surface is found in the cache.

This fixes an issue where the Surface readFromParcel code was leaving
unread parcel data in the case where the Surface was re-used from the
sCachedSurfaces cache. On a cache miss the code is creating a new
Surface from the remainder of the parcel data. On a hit that data was
being left unread, so anything that parcels a Surface followed by
additional arguments may end up reading the wrong values.

Change-Id: I25365159d945c125bd1fcc9f17e39a4f00aece55
parent c993acbc
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -277,6 +277,11 @@ sp<Surface> Surface::readFromParcel(const Parcel& data) {
    if (surface == 0) {
    if (surface == 0) {
       surface = new Surface(data, binder);
       surface = new Surface(data, binder);
       sCachedSurfaces.add(binder, surface);
       sCachedSurfaces.add(binder, surface);
    } else {
        // The Surface was found in the cache, but we still should clear any
        // remaining data from the parcel.
        data.readStrongBinder();  // ISurfaceTexture
        data.readInt32();         // identity
    }
    }
    if (surface->mSurface == NULL && surface->getISurfaceTexture() == NULL) {
    if (surface->mSurface == NULL && surface->getISurfaceTexture() == NULL) {
        surface = 0;
        surface = 0;