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

Commit 54d50089 authored by Ian McKellar's avatar Ian McKellar
Browse files

Check for null in LocalSocketImpl.SocketInputStream.available()

Calling available() on a local socket after close() will cause a native
crash. Other methods that pass LocalSocketImpl.fd to native code copy
the fd and check for null.

Change-Id: I2d0b573f34ae47a23009760bbb1c02933ab0a20e
parent 4f4892d0
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -56,7 +56,10 @@ class LocalSocketImpl
        /** {@inheritDoc} */
        /** {@inheritDoc} */
        @Override
        @Override
        public int available() throws IOException {
        public int available() throws IOException {
            return available_native(fd);
            FileDescriptor myFd = fd;
            if (myFd == null) throw new IOException("socket closed");

            return available_native(myFd);
        }
        }


        /** {@inheritDoc} */
        /** {@inheritDoc} */