Skip to content

Commit f452e11

Browse files
committed
Fix ResourceID validation check expression
there are three methods which have wrong expression getFallbackDrawable() getErrorDrawable() getPlaceholderDrawable() According to the official documentation, resourceID can have a negative value, so I modified the if statement logic to include correct validation.
1 parent a7351b0 commit f452e11

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

library/src/main/java/com/bumptech/glide/request/SingleRequest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ public boolean isAnyResourceSet() {
387387
private Drawable getErrorDrawable() {
388388
if (errorDrawable == null) {
389389
errorDrawable = requestOptions.getErrorPlaceholder();
390-
if (errorDrawable == null && requestOptions.getErrorId() > 0) {
390+
if (errorDrawable == null && requestOptions.getErrorId() != -1 &&
391+
(requestOptions.getErrorId() & 0xff000000) != 0 && (requestOptions.getErrorId() & 0x00ff0000) != 0) {
391392
errorDrawable = loadDrawable(requestOptions.getErrorId());
392393
}
393394
}
@@ -398,7 +399,8 @@ private Drawable getErrorDrawable() {
398399
private Drawable getPlaceholderDrawable() {
399400
if (placeholderDrawable == null) {
400401
placeholderDrawable = requestOptions.getPlaceholderDrawable();
401-
if (placeholderDrawable == null && requestOptions.getPlaceholderId() > 0) {
402+
if (placeholderDrawable == null && requestOptions.getPlaceholderId() != -1 &&
403+
(requestOptions.getPlaceholderId() & 0xff000000) != 0 && (requestOptions.getPlaceholderId() & 0x00ff0000) != 0) {
402404
placeholderDrawable = loadDrawable(requestOptions.getPlaceholderId());
403405
}
404406
}
@@ -409,7 +411,8 @@ private Drawable getPlaceholderDrawable() {
409411
private Drawable getFallbackDrawable() {
410412
if (fallbackDrawable == null) {
411413
fallbackDrawable = requestOptions.getFallbackDrawable();
412-
if (fallbackDrawable == null && requestOptions.getFallbackId() > 0) {
414+
if (fallbackDrawable == null && requestOptions.getFallbackId() != -1 &&
415+
(requestOptions.getFallbackId() & 0xff000000) != 0 && (requestOptions.getFallbackId() & 0x00ff0000) != 0) {
413416
fallbackDrawable = loadDrawable(requestOptions.getFallbackId());
414417
}
415418
}

0 commit comments

Comments
 (0)