summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2020-03-11 17:48:31 -0700
committerSteven Moreland <smoreland@google.com>2020-03-18 18:00:41 +0000
commit4271f564399e35186473ccd2d70b45bb5038c97a (patch)
treeb35f1abda22d47c6396860d6d34a8b05070021c2
parent40566cafac55028a99ae03d1b487a6b0f8be8299 (diff)
downloadandroid_frameworks_native-4271f564399e35186473ccd2d70b45bb5038c97a.tar.gz
android_frameworks_native-4271f564399e35186473ccd2d70b45bb5038c97a.tar.bz2
android_frameworks_native-4271f564399e35186473ccd2d70b45bb5038c97a.zip
sf: avoid assumption remote binder is local
We are lucky that a test was passing a remote binder here and that I happened to reorder elements in BpBinder, since this caused a crash, where before, 'owner' was getting set to some random bits inside of a BpBinder object. Bug: 150904694 Test: move mTrackingUid around in BpBinder, then `atest CompositionSamplingListenerTest` passes Change-Id: I552a669113844a6b7ceaba5a1197fd04ca7e18d5 Merged-In: I552a669113844a6b7ceaba5a1197fd04ca7e18d5 (cherry picked from commit 858c55f73a760a06ac398562a9274641239e1322)
-rw-r--r--services/surfaceflinger/RegionSamplingThread.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp
index 66906e950..8e7386df0 100644
--- a/services/surfaceflinger/RegionSamplingThread.cpp
+++ b/services/surfaceflinger/RegionSamplingThread.cpp
@@ -197,9 +197,10 @@ RegionSamplingThread::~RegionSamplingThread() {
void RegionSamplingThread::addListener(const Rect& samplingArea, const sp<IBinder>& stopLayerHandle,
const sp<IRegionSamplingListener>& listener) {
- wp<Layer> stopLayer = stopLayerHandle != nullptr
- ? static_cast<Layer::Handle*>(stopLayerHandle.get())->owner
- : nullptr;
+ wp<Layer> stopLayer;
+ if (stopLayerHandle != nullptr && stopLayerHandle->localBinder() != nullptr) {
+ stopLayer = static_cast<Layer::Handle*>(stopLayerHandle.get())->owner;
+ }
sp<IBinder> asBinder = IInterface::asBinder(listener);
asBinder->linkToDeath(this);