Merge "Fix possible leak in Parcel::writeDupFileDescriptor."

This commit is contained in:
Jeff Brown 2011-11-07 14:05:22 -08:00 committed by Android (Google) Code Review
commit e22d8ef574

View File

@ -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)