You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue details / Repro steps / Use case background:
I am using Glide in dfm and save the image in the drawble folder so that an error image is displayed when the image load fails as shown below.
In the Glide library version 4.14.2, there is an issue with the method getErrorDrawable() located in the com.bumptech.glide.request.SingleRequest<R> class, specifically at line 386. The method is defined as follows:
The conditional check requestOptions.getErrorId() > 0 is problematic because Android resource IDs can be negative values. Thus, this code may lead to incorrect behavior by not properly handling cases where the error ID is negative. This oversight could prevent the loading of valid negative resource IDs as error drawables.
See the static method isValid(@AynRes int id) located in the android.content.res.ResourceId class.
/**
* Checks whether the integer {@code id} is a valid resource ID, as generated by AAPT.
* <p>Note that a negative integer is not necessarily an invalid resource ID, and custom
* validations that compare the {@code id} against {@code 0} are incorrect.</p>
* @param id The integer to validate.
* @return {@code true} if the integer is a valid resource ID.
*/
public static boolean isValid(@AnyRes int id) {
// With the introduction of packages with IDs > 0x7f, resource IDs can be negative when
// represented as a signed Java int. Some legacy code assumes -1 is an invalid resource ID,
// despite the existing documentation.
return id != -1 && (id & 0xff000000) != 0 && (id & 0x00ff0000) != 0;
}
Glide Version: 4.11.0
Integration libraries:
Device/Android Version: any devices
Issue details / Repro steps / Use case background:
I am using Glide in dfm and save the image in the drawble folder so that an error image is displayed when the image load fails as shown below.
If the resource id value of R.drawable.xxxxx is a negative integer, it will not operate. If it is a positive integer, it will operate normally.
Are you separately checking the validity of the errorId value saved in the above function?
The text was updated successfully, but these errors were encountered: