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

Commit 073c9c19 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder_ndk: don't borrow fd into unique_fd

Some tests are checking that this fd isn't double-owned, but it appears
to be for a brief duration. Instead, avoiding creating a
ParcelFileDescriptor at all.

Fixes: 149851140
Test: CtsNdkBinderTestCases
Change-Id: Ibb90203bd7b9c9481756df64b84c048d01f0843e
parent 15ebf445
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -247,15 +247,12 @@ binder_status_t AParcel_writeParcelFileDescriptor(AParcel* parcel, int fd) {
        if (fd != -1) {
            return STATUS_UNKNOWN_ERROR;
        }
        return parcel->get()->writeInt32(0);  // null
        return PruneStatusT(parcel->get()->writeInt32(0));  // null
    }
    status_t status = parcel->get()->writeInt32(1);  // not-null
    if (status != STATUS_OK) return PruneStatusT(status);

    ParcelFileDescriptor parcelFd = ParcelFileDescriptor(unique_fd(fd));
    status_t status = parcel->get()->writeParcelable(parcelFd);

    // ownership is retained by caller
    (void)parcelFd.release().release();

    status = parcel->get()->writeDupParcelFileDescriptor(fd);
    return PruneStatusT(status);
}