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

Commit 69a5f6c3 authored by Andreas Huber's avatar Andreas Huber
Browse files

Properly serialize access to FileSource::getSize by acquiring the mutex

Both ::getSize and ::read call into lseek64, if this happens simultaneously
from multiple threads the results are undefined if not properly serialized.

Change-Id: I737cafebd836f3d8eb702beac557b4731f69c6f6
related-to-bug: 5196490
parent bffb83e9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -110,6 +110,8 @@ ssize_t FileSource::readAt(off64_t offset, void *data, size_t size) {
}

status_t FileSource::getSize(off64_t *size) {
    Mutex::Autolock autoLock(mLock);

    if (mFd < 0) {
        return NO_INIT;
    }