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

Commit 35ce4a7c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix fd leak in Binder"

parents 132bfe70 d84ff314
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -2094,11 +2094,15 @@ status_t Parcel::read(FlattenableHelperInterface& val) const

    status_t err = NO_ERROR;
    for (size_t i=0 ; i<fd_count && err==NO_ERROR ; i++) {
        fds[i] = dup(this->readFileDescriptor());
        if (fds[i] < 0) {
        int fd = this->readFileDescriptor();
        if (fd < 0 || ((fds[i] = dup(fd)) < 0)) {
            err = BAD_VALUE;
            ALOGE("dup() failed in Parcel::read, i is %zu, fds[i] is %d, fd_count is %zu, error: %s",
                i, fds[i], fd_count, strerror(errno));
                  i, fds[i], fd_count, strerror(fd < 0 ? -fd : errno));
            // Close all the file descriptors that were dup-ed.
            for (size_t j=0; j<i ;j++) {
                close(fds[j]);
            }
        }
    }