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

Commit b203ac2f authored by Chris Wailes's avatar Chris Wailes
Browse files

Fixed a nullptr exception in ZygoteProcess.java.

This patch fixes a nullptr exception in ZygoteProcess caused by
ChildZygoteProcess not providing the ZygoteState with a secondary zygote
socket address.

Test: Launch Chrome with the USAP pool enabled
Change-Id: Ie13d2c1a84a79fbc45b4913aeb1d78b442201479
parent 07c6f4d4
Loading
Loading
Loading
Loading
+27 −23
Original line number Diff line number Diff line
@@ -120,10 +120,6 @@ public class ZygoteProcess {
        mUsapPoolSecondarySocketAddress =
                new LocalSocketAddress(Zygote.USAP_POOL_SECONDARY_SOCKET_NAME,
                                       LocalSocketAddress.Namespace.RESERVED);

        if (fetchUsapPoolEnabledProp()) {
            informZygotesOfUsapPoolStatus();
        }
    }

    public ZygoteProcess(LocalSocketAddress primarySocketAddress,
@@ -179,14 +175,18 @@ public class ZygoteProcess {
         * address
         * @throws IOException
         */
        public static ZygoteState connect(LocalSocketAddress zygoteSocketAddress,
                                          LocalSocketAddress usapSocketAddress)
        public static ZygoteState connect(@NonNull LocalSocketAddress zygoteSocketAddress,
                                          @Nullable LocalSocketAddress usapSocketAddress)
                throws IOException {

            DataInputStream zygoteInputStream = null;
            BufferedWriter zygoteOutputWriter = null;
            final LocalSocket zygoteSessionSocket = new LocalSocket();

            if (zygoteSocketAddress == null) {
                throw new IllegalArgumentException("zygoteSocketAddress can't be null");
            }

            try {
                zygoteSessionSocket.connect(zygoteSocketAddress);
                zygoteInputStream = new DataInputStream(zygoteSessionSocket.getInputStream());
@@ -919,12 +919,14 @@ public class ZygoteProcess {
                return primaryZygoteState;
            }

            if (mZygoteSecondarySocketAddress != null) {
                // The primary zygote didn't match. Try the secondary.
                attemptConnectionToSecondaryZygote();

                if (secondaryZygoteState.matches(abi)) {
                    return secondaryZygoteState;
                }
            }
        } catch (IOException ioe) {
            throw new ZygoteStartFailedEx("Error connecting to zygote", ioe);
        }
@@ -1071,6 +1073,7 @@ public class ZygoteProcess {
                return;
            }

            if (mZygoteSecondarySocketAddress != null) {
                try {
                    attemptConnectionToSecondaryZygote();

@@ -1088,6 +1091,7 @@ public class ZygoteProcess {
                } catch (IOException ioe) {
                    // No secondary zygote present.  This is expected on some devices.
                }
            }

            // Wait for the response from the primary zygote here so the primary/secondary zygotes
            // can work concurrently.