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

Commit 75ef1405 authored by George Burgess IV's avatar George Burgess IV Committed by Automerger Merge Worker
Browse files

Merge "binder: don't dereference NULL" am: b08c2cb6 am: 0f2dc478 am: 95384c2c am: 8d71f10b

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1771046

Change-Id: I0d5a7c5fc12ab3e8774957952ce79bf365d4c312
parents 917014d8 8d71f10b
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -111,15 +111,15 @@ android::base::Result<CommandResult> execute(std::vector<std::string> argStringV
    errWrite.reset();
    ret.pid = pid;

    auto handlePoll = [](android::base::unique_fd* fd, const pollfd& pfd, std::string* s) {
    auto handlePoll = [](android::base::unique_fd* fd, const pollfd* pfd, std::string* s) {
        if (!fd->ok()) return true;
        if (pfd.revents & POLLIN) {
        if (pfd->revents & POLLIN) {
            char buf[1024];
            ssize_t n = TEMP_FAILURE_RETRY(read(fd->get(), buf, sizeof(buf)));
            if (n < 0) return false;
            if (n > 0) *s += std::string_view(buf, n);
        }
        if (pfd.revents & POLLHUP) {
        if (pfd->revents & POLLHUP) {
            fd->reset();
        }
        return true;
@@ -142,9 +142,9 @@ android::base::Result<CommandResult> execute(std::vector<std::string> argStringV
        int pollRet = poll(fds, nfds, 1000 /* ms timeout */);
        if (pollRet == -1) return android::base::ErrnoError() << "poll()";

        if (!handlePoll(&ret.outPipe, *outPollFd, &ret.stdout))
        if (!handlePoll(&ret.outPipe, outPollFd, &ret.stdout))
            return android::base::ErrnoError() << "read(stdout)";
        if (!handlePoll(&ret.errPipe, *errPollFd, &ret.stderr))
        if (!handlePoll(&ret.errPipe, errPollFd, &ret.stderr))
            return android::base::ErrnoError() << "read(stderr)";

        if (end && end(ret)) return ret;