diff options
| author | 2019-09-17 14:13:18 -0400 | |
|---|---|---|
| committer | 2019-09-17 14:13:18 -0400 | |
| commit | 3d7ae4efffcf3c4cbe17131a76d3020107d051fb (patch) | |
| tree | 1e8736dacd199f9d58b9827e17c53de99b53bf1c /graphics/java/android | |
| parent | 081deafca597c61d4e7e73083ff685e64034c9cc (diff) | |
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
Diffstat (limited to 'graphics/java/android')
| -rw-r--r-- | graphics/java/android/graphics/ImageDecoder.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/ImageDecoder.java b/graphics/java/android/graphics/ImageDecoder.java index 150a941c061e..6619dba159c2 100644 --- a/graphics/java/android/graphics/ImageDecoder.java +++ b/graphics/java/android/graphics/ImageDecoder.java @@ -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(); |