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

Commit 58c1579c authored by Wei-Ta Chen's avatar Wei-Ta Chen
Browse files

Fix 3122139, where previewing an attachment for the second time will

fail.

Use AutoFDSeek to mark and restore the position before we read data from
the descriptor.

Change-Id: I3d4f012dce486e19b113bc90a98b94031cfa8195
parent a376d030
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ static SkMemoryStream* buildSkMemoryStream(SkStream *stream) {
        }
    }
    data = (char*)sk_realloc_throw(data, streamLen);

    SkMemoryStream* streamMem = new SkMemoryStream();
    streamMem->setMemoryOwned(data, streamLen);
    return streamMem;
@@ -133,6 +134,12 @@ static jobject nativeNewInstanceFromFileDescriptor(JNIEnv* env, jobject clazz,
        }
        stream = fdStream;
    } else {
        /* Restore our offset when we leave, so we can be called more than once
           with the same descriptor. This is only required if we didn't dup the
           file descriptor, but it is OK to do it all the time.
        */
        AutoFDSeek as(descriptor);

        SkFDStream* fdStream = new SkFDStream(descriptor, false);
        if (!fdStream->isValid()) {
            fdStream->unref();
@@ -142,12 +149,6 @@ static jobject nativeNewInstanceFromFileDescriptor(JNIEnv* env, jobject clazz,
        fdStream->unref();
    }

    /* Restore our offset when we leave, so we can be called more than once
       with the same descriptor. This is only required if we didn't dup the
       file descriptor, but it is OK to do it all the time.
    */
    AutoFDSeek as(descriptor);

    return doBuildTileIndex(env, stream);
}