mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
WebPPictureHasTransparency: add missing pointer check
in the case of use_argb, alpha_offset may be non-zero which would cause the null pointer check in CheckNonOpaque to pass fixes a potential crash with invalid width/height set or an integer sanitizer warning when passing a zeroed picture: src/enc/picture_csp_enc.c:73:57: runtime error: applying non-zero offset 3 to null pointer Change-Id: I9d499bba12c65ad5c65d8f9f3c8ee9298ac6081a
This commit is contained in:
parent
866e349cef
commit
1a6c109c99
@ -70,9 +70,12 @@ int WebPPictureHasTransparency(const WebPPicture* picture) {
|
||||
if (picture == NULL) return 0;
|
||||
if (picture->use_argb) {
|
||||
const int alpha_offset = ALPHA_OFFSET;
|
||||
return CheckNonOpaque((const uint8_t*)picture->argb + alpha_offset,
|
||||
picture->width, picture->height,
|
||||
4, picture->argb_stride * sizeof(*picture->argb));
|
||||
if (picture->argb != NULL) {
|
||||
return CheckNonOpaque((const uint8_t*)picture->argb + alpha_offset,
|
||||
picture->width, picture->height,
|
||||
4, picture->argb_stride * sizeof(*picture->argb));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return CheckNonOpaque(picture->a, picture->width, picture->height,
|
||||
1, picture->a_stride);
|
||||
|
Loading…
Reference in New Issue
Block a user