summaryrefslogtreecommitdiff
path: root/libs/binder/Parcel.cpp
diff options
context:
space:
mode:
author Jeff Brown <jeffbrown@google.com> 2011-11-07 15:51:31 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2011-11-07 15:51:31 +0000
commitbd79a9c9f39482b3a9560d03cb045ec4e3b87486 (patch)
tree90d3ebbe31b26daa57c670ab884bbadc46a6f062 /libs/binder/Parcel.cpp
parent2abb2abea05fddd9ec2a1d6c831f1e62c37c7fa3 (diff)
parent88061d6b38cfb4bf374039846b753a3b21ac61e1 (diff)
am 88061d6b: am 5462bc63: Fix a leak in Parcel::writeBlob.
* commit '88061d6b38cfb4bf374039846b753a3b21ac61e1': Fix a leak in Parcel::writeBlob.
Diffstat (limited to 'libs/binder/Parcel.cpp')
-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 c557b038dc34..26571ce970f9 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;