diff options
author | Pierre Joye <pierre.php@gmail.com> | 2021-08-13 21:14:36 +0700 |
---|---|---|
committer | Pierre Joye <pierre.php@gmail.com> | 2021-08-13 21:14:36 +0700 |
commit | bd72a7da404deca517cdbe385c222d9dc5d0e62d (patch) | |
tree | ae378eb9f7afaf22af3154cfcd66fb07a9d94c09 /src | |
parent | dfe1ecb8a999418dcfe2224da0c515e565977940 (diff) | |
download | libgd-bd72a7da404deca517cdbe385c222d9dc5d0e62d.tar.gz |
WebP: Fix memory leak in test and avoid possible memory leak if size is not correct (ie. passing 0 size will leak). Min size is the WebP sign (3x32bits)
Diffstat (limited to 'src')
-rw-r--r-- | src/gd_webp.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gd_webp.c b/src/gd_webp.c index d887b71..1622310 100644 --- a/src/gd_webp.c +++ b/src/gd_webp.c @@ -356,6 +356,16 @@ BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size) BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quality) { void *rv; + + /* + WebP Header is 3x32bits + RIFF + filesize + WEBP + */ + if (size < 96) { + return NULL; + } gdIOCtx *out = gdNewDynamicCtx(2048, NULL); if (out == NULL) { return NULL; |