summaryrefslogtreecommitdiffstats
path: root/libs/binder
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-11-07 15:51:31 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2011-11-07 15:51:31 +0000
commitc17f56fdf11d5c5207d02d457692a40252aa3f34 (patch)
tree689f206d19097915136cf75aa06d4caf0af5c551 /libs/binder
parent2d3f094611619b40fd54a9c24d006a30c447a359 (diff)
parentefd912c05c0ef550a1c5ba7a14281261f6a0f9f4 (diff)
downloadframeworks_native-c17f56fdf11d5c5207d02d457692a40252aa3f34.zip
frameworks_native-c17f56fdf11d5c5207d02d457692a40252aa3f34.tar.gz
frameworks_native-c17f56fdf11d5c5207d02d457692a40252aa3f34.tar.bz2
am 88061d6b: am 5462bc63: Fix a leak in Parcel::writeBlob.
* commit '88061d6b38cfb4bf374039846b753a3b21ac61e1': Fix a leak in Parcel::writeBlob.
Diffstat (limited to 'libs/binder')
-rw-r--r--libs/binder/Parcel.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index c557b03..26571ce 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -710,24 +710,19 @@ status_t Parcel::writeNativeHandle(const native_handle* handle)
return err;
}
-status_t Parcel::writeFileDescriptor(int fd)
+status_t Parcel::writeFileDescriptor(int fd, bool takeOwnership)
{
flat_binder_object obj;
obj.type = BINDER_TYPE_FD;
obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
obj.handle = fd;
- obj.cookie = (void*)0;
+ obj.cookie = (void*) (takeOwnership ? 1 : 0);
return writeObject(obj, true);
}
status_t Parcel::writeDupFileDescriptor(int fd)
{
- flat_binder_object obj;
- obj.type = BINDER_TYPE_FD;
- obj.flags = 0x7f | FLAT_BINDER_FLAG_ACCEPTS_FDS;
- obj.handle = dup(fd);
- obj.cookie = (void*)1;
- return writeObject(obj, true);
+ return writeFileDescriptor(dup(fd), true /*takeOwnership*/);
}
status_t Parcel::writeBlob(size_t len, WritableBlob* outBlob)
@@ -764,7 +759,7 @@ status_t Parcel::writeBlob(size_t len, WritableBlob* outBlob)
} else {
status = writeInt32(1);
if (!status) {
- status = writeFileDescriptor(fd);
+ status = writeFileDescriptor(fd, true /*takeOwnership*/);
if (!status) {
outBlob->init(true /*mapped*/, ptr, len);
return NO_ERROR;