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

Commit 3d7ae4ef authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

ImageDecoder: throw FileNotFoundException on null

Bug: 140961740
Test: I41a93b47acde6a7985c53107f448a8b647d245d7

If ImageDecoder has a null AssetFileDescriptor, either from a Callable
or from a ContentResolver directly, throw a FileNotFoundException.
Previously, a NullPointerException was thrown attempting to dereference
it.

Change-Id: Ie738b9edc062e520835010befc001578fce09832
parent 081deafc
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -286,6 +286,9 @@ public final class ImageDecoder implements AutoCloseable {

                return createFromStream(is, true, preferAnimation, this);
            }
            if (assetFd == null) {
                throw new FileNotFoundException(mUri.toString());
            }
            return createFromAssetFileDescriptor(assetFd, preferAnimation, this);
        }
    }
@@ -341,6 +344,9 @@ public final class ImageDecoder implements AutoCloseable {
    @NonNull
    private static ImageDecoder createFromAssetFileDescriptor(@NonNull AssetFileDescriptor assetFd,
            boolean preferAnimation, Source source) throws IOException {
        if (assetFd == null) {
            throw new FileNotFoundException();
        }
        final FileDescriptor fd = assetFd.getFileDescriptor();
        final long offset = assetFd.getStartOffset();