Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d341c717 authored by Jeff Brown's avatar Jeff Brown
Browse files

Fix possible leak in Parcel::writeDupFileDescriptor.

Also, check the result of dup() just in case we got EMFILE
or something.

Change-Id: I18e627bd84f4c7941813fe1c2bad2cdd9e5afa83
parent be37dde7
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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)