Skip to content

Commit af67fc6

Browse files
author
Jeff Brown
committed
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
1 parent c042ee2 commit af67fc6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/java/android/content/res/AssetFileDescriptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class AssetFileDescriptor implements Parcelable {
5252
*/
5353
public AssetFileDescriptor(ParcelFileDescriptor fd, long startOffset,
5454
long length) {
55+
if (fd == null) {
56+
throw new IllegalArgumentException("fd must not be null");
57+
}
5558
if (length < 0 && startOffset != 0) {
5659
throw new IllegalArgumentException(
5760
"startOffset must be 0 when using UNKNOWN_LENGTH");

0 commit comments

Comments
 (0)