|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-01-27 21:33 UTC] hbengali at chromium dot org
Description: ------------ --- From manual page: http://www.php.net/function.imagewebp --- The latest version of libwebp (0.4.0) needs to be used here. Use of the older version causes inconsistencies when rendering in browsers that use libwebp 0.4.0. For example: https://code.google.com/p/webp/issues/detail?id=185 libwebp 0.4.0 can be found here: https://code.google.com/p/webp/downloads/detail?name=libwebp-0.4.0.tar.gz&can=2&q= PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Here is a proposed fix from one of the WebP developers with the disclaimer that it is untested and may have incorrect local style. diff --git a/ext/gd/libgd/webpimg.c b/ext/gd/libgd/webpimg.c index 01bef93..ca4e9bc 100644 --- a/ext/gd/libgd/webpimg.c +++ b/ext/gd/libgd/webpimg.c @@ -778,6 +778,18 @@ WebPResult WebPEncode(const uint8* Y, (chunk_size >> 16) & 255, (chunk_size >> 24) & 255 }; memcpy(*p_out, kRiffHeader, kRiffHeaderSize); + if (img_size_bytes & 1) { /* write a padding byte */ + const int new_size = *p_out_size_bytes + 1; + unsigned char* p = (unsigned char*)realloc(*p_out, new_size); + if (p == NULL) { + free(*p_out); + *p_out = NULL; + *p_out_size_bytes = 0; + return webp_failure; + } + p[new_size - 1] = 0; + *p_out_size_bytes = new_size; + } if (psnr) { *psnr = WebPGetPSNR(Y, U, V, *p_out, *p_out_size_bytes);