diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2018-07-17 14:20:08 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2018-07-17 14:20:08 +0300 |
commit | 9b1c3a4c5e0151d3c967b1734ea52b3298a85e69 (patch) | |
tree | 5f103cb4f1e108d4d42309fd2e2e1150b2373a80 | |
parent | 116770cb3f53f334f91c9dbd5bbb66b2c82d2508 (diff) | |
download | qtlocation-mapboxgl-upstream/tmpsantos-android_race.tar.gz |
[android] Fix possibly race on undefined behaviorupstream/tmpsantos-android_race
`runnable->iter = runnables.end()` assumes that `::end()` is a
`static` or `constxpr` and thread-safe. This is likely to be true
for most of the implementations. That said we cannot rely on
undefined behavior and we should assume the worse case scenario.
-rw-r--r-- | platform/android/src/run_loop.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/platform/android/src/run_loop.cpp b/platform/android/src/run_loop.cpp index f655f13ea8..b55f2be190 100644 --- a/platform/android/src/run_loop.cpp +++ b/platform/android/src/run_loop.cpp @@ -167,6 +167,7 @@ void RunLoop::Impl::removeRunnable(Runnable* runnable) { } void RunLoop::Impl::initRunnable(Runnable* runnable) { + std::lock_guard<std::recursive_mutex> lock(mtx); runnable->iter = runnables.end(); } |