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

Commit 009ff0dd authored by Dongwon Kang's avatar Dongwon Kang
Browse files

Protect sp assignments in RemoteDataSource.

sp assignments is not thread safe and close also can be called from
binder clean-up procedure on the separate thread.

Test: cts-tradefed run cts -m CtsMediaTestCases -t android.media.cts.MediaPlayerTest#testVorbisCrash
Bug: 62251555
Change-Id: I3e5f42d87b490f4aadfa17276632783545611cdc
parent 8631fd7b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -54,6 +54,9 @@ public:
        return mSource->getSize(size);
    }
    virtual void close() {
        // Protect strong pointer assignments. This also can be called from the binder
        // clean-up procedure which is running on a separate thread.
        Mutex::Autolock lock(mCloseLock);
        mSource = nullptr;
        mMemory = nullptr;
    }
@@ -75,6 +78,7 @@ private:
    sp<IMemory> mMemory;
    sp<DataSource> mSource;
    String8 mName;
    Mutex mCloseLock;

    explicit RemoteDataSource(const sp<DataSource> &source) {
        mSource = source;