mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-28 06:38:20 +01:00
fix alpha-filtering crash when image width is larger than radius
(we also limit radius based on height too, for good measure, although it's not an asan bug) fixes oss-fuzz issue #9105 BUG=webp:512 Change-Id: Ie0d79dd81480dc4e2b653b7e992e5cdcd3dfa834 (cherry picked from commit1344a2e947
) (cherry picked from commit61ff26aeeb
)
This commit is contained in:
parent
47768596f6
commit
2ccbb406e1
@ -261,9 +261,15 @@ static void CleanupParams(SmoothParams* const p) {
|
|||||||
|
|
||||||
int WebPDequantizeLevels(uint8_t* const data, int width, int height, int stride,
|
int WebPDequantizeLevels(uint8_t* const data, int width, int height, int stride,
|
||||||
int strength) {
|
int strength) {
|
||||||
const int radius = 4 * strength / 100;
|
int radius = 4 * strength / 100;
|
||||||
|
|
||||||
if (strength < 0 || strength > 100) return 0;
|
if (strength < 0 || strength > 100) return 0;
|
||||||
if (data == NULL || width <= 0 || height <= 0) return 0; // bad params
|
if (data == NULL || width <= 0 || height <= 0) return 0; // bad params
|
||||||
|
|
||||||
|
// limit the filter size to not exceed the image dimensions
|
||||||
|
if (2 * radius + 1 > width) radius = (width - 1) >> 1;
|
||||||
|
if (2 * radius + 1 > height) radius = (height - 1) >> 1;
|
||||||
|
|
||||||
if (radius > 0) {
|
if (radius > 0) {
|
||||||
SmoothParams p;
|
SmoothParams p;
|
||||||
memset(&p, 0, sizeof(p));
|
memset(&p, 0, sizeof(p));
|
||||||
|
Loading…
Reference in New Issue
Block a user