From cb5c9156c233a260e7a588141863720de82d2926 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 17 Feb 2004 21:30:00 +0000 Subject: [PATCH] Fixed bug #27293 (two crashes inside image2wbmp()). --- ext/gd/gd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index d43c7e625c..1ce674e2d5 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1724,6 +1724,8 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char if (q < 0 || q > 255) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid threshold value '%d'. It must be between 0 and 255", q); } + gdImageWBMP(im, q, fp); + break; case PHP_GDIMG_TYPE_JPG: (*func_p)(im, fp, q); break; @@ -1766,6 +1768,8 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char if (q < 0 || q > 255) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid threshold value '%d'. It must be between 0 and 255", q); } + gdImageWBMP(im, q, tmp); + break; case PHP_GDIMG_TYPE_JPG: (*func_p)(im, tmp, q); break; @@ -3741,6 +3745,10 @@ static void _php_image_bw_convert(gdImagePtr im_org, gdIOCtx *out, int threshold return; } + if (im_org->trueColor) { + gdImageTrueColorToPalette(im_org, 1, 256); + } + for (y = 0; y < dest_height; y++) { for (x = 0; x < dest_width; x++) { color_org = gdImageGetPixel(im_org, x, y); -- 2.40.0