summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-11-04 20:19:33 -0700
committerJeff Brown <jeffbrown@google.com>2011-11-07 12:22:39 -0800
commitdf4ee721cbb3d33879be1ca09017710abd20a9ed (patch)
tree2f0122da5f54a9440618829e36f112922b1ec924 /libs
parentff92dd69af5d95c00ef6ce9285c97d3e937cd704 (diff)
downloadframeworks_base-df4ee721cbb3d33879be1ca09017710abd20a9ed.zip
frameworks_base-df4ee721cbb3d33879be1ca09017710abd20a9ed.tar.gz
frameworks_base-df4ee721cbb3d33879be1ca09017710abd20a9ed.tar.bz2
Fix possible leak in Parcel::writeDupFileDescriptor.
Also, check the result of dup() just in case we got EMFILE or something. Change-Id: I18e627bd84f4c7941813fe1c2bad2cdd9e5afa83
Diffstat (limited to 'libs')
-rw-r--r--libs/binder/Parcel.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 26571ce..6cd43aa 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -722,7 +722,15 @@ status_t Parcel::writeFileDescriptor(int fd, bool takeOwnership)
status_t Parcel::writeDupFileDescriptor(int fd)
{
- return writeFileDescriptor(dup(fd), true /*takeOwnership*/);
+ int dupFd = dup(fd);
+ if (dupFd < 0) {
+ return -errno;
+ }
+ status_t err = writeFileDescriptor(dupFd, true /*takeOwnership*/);
+ if (err) {
+ close(dupFd);
+ }
+ return err;
}
status_t Parcel::writeBlob(size_t len, WritableBlob* outBlob)