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

Commit af67fc65 authored by Jeff Brown's avatar Jeff Brown
Browse files

Check for null fd when constructing AssetFileDescriptor.

An AssetFileDescriptor with a null fd is pretty useless and should
never happen during normal operation.  It can't even be parcelled
without hitting an NPE.  To make it easier to find bugs where a null
fd might have been generated, check at construction time.

Bug: 5655036
Change-Id: I1da6dbee0cab9c11e309f3cebe698bf44dc5e27d
parent c042ee2a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ public class AssetFileDescriptor implements Parcelable {
     */
    public AssetFileDescriptor(ParcelFileDescriptor fd, long startOffset,
            long length) {
        if (fd == null) {
            throw new IllegalArgumentException("fd must not be null");
        }
        if (length < 0 && startOffset != 0) {
            throw new IllegalArgumentException(
                    "startOffset must be 0 when using UNKNOWN_LENGTH");