summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andy Hung <hunga@google.com> 2020-03-12 01:23:50 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-03-12 01:23:50 +0000
commit42ee916c1f5d2c38a400e32908d7a6e11a92a8f4 (patch)
tree732a2e152de64efda0b8067001dfb92fc4b32a41
parent592181386c651aa12975db5b38d7550d050b8dd2 (diff)
parent9bebf81345a5e9dd717d2c1027d3f4354d22d9ef (diff)
Merge "SoundPool: Set completion flag before promise" into rvc-dev
-rw-r--r--media/jni/soundpool/StreamManager.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/media/jni/soundpool/StreamManager.h b/media/jni/soundpool/StreamManager.h
index 15b39f2df891..30ad220db05b 100644
--- a/media/jni/soundpool/StreamManager.h
+++ b/media/jni/soundpool/StreamManager.h
@@ -70,9 +70,10 @@ private:
static int staticFunction(void *data) {
JavaThread *jt = static_cast<JavaThread *>(data);
jt->mF();
+ jt->mIsClosed = true; // set the flag that we are closed
+ // now before we allow the destructor to execute;
+ // otherwise there may be a use after free.
jt->mPromise.set_value();
- jt->mIsClosed = true; // publicly inform that we are closed
- // after we have accessed all variables.
return 0;
}