summaryrefslogtreecommitdiffstats
path: root/libs/binder/IPCThreadState.cpp
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-12-13 02:15:45 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-12-13 02:15:45 +0100
commitd3ad4f1e64dfe162c03fbbbe79c21c3c20641f18 (patch)
treea21f7d76365795800eebfd006d34803a9304e04c /libs/binder/IPCThreadState.cpp
parentb2381c3e4b90d845d9713b7b29d64317b7f21ce8 (diff)
parentb22bca465e55618a949d9cbdea665a1a3a831241 (diff)
downloadframeworks_native-d3ad4f1e64dfe162c03fbbbe79c21c3c20641f18.zip
frameworks_native-d3ad4f1e64dfe162c03fbbbe79c21c3c20641f18.tar.gz
frameworks_native-d3ad4f1e64dfe162c03fbbbe79c21c3c20641f18.tar.bz2
Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_frameworks_native into replicant-6.0
Diffstat (limited to 'libs/binder/IPCThreadState.cpp')
-rw-r--r--libs/binder/IPCThreadState.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index ef88181..af18e11 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -1083,8 +1083,16 @@ status_t IPCThreadState::executeCommand(int32_t cmd)
<< reinterpret_cast<const size_t*>(tr.data.ptr.offsets) << endl;
}
if (tr.target.ptr) {
- sp<BBinder> b((BBinder*)tr.cookie);
- error = b->transact(tr.code, buffer, &reply, tr.flags);
+ // We only have a weak reference on the target object, so we must first try to
+ // safely acquire a strong reference before doing anything else with it.
+ if (reinterpret_cast<RefBase::weakref_type*>(
+ tr.target.ptr)->attemptIncStrong(this)) {
+ error = reinterpret_cast<BBinder*>(tr.cookie)->transact(tr.code, buffer,
+ &reply, tr.flags);
+ reinterpret_cast<BBinder*>(tr.cookie)->decStrong(this);
+ } else {
+ error = UNKNOWN_TRANSACTION;
+ }
} else {
error = the_context_object->transact(tr.code, buffer, &reply, tr.flags);