From: Mitch Hagstrand Date: Sat, 21 Jan 2017 20:40:15 +0000 (-0800) Subject: Fix intermittent segfault in GD library X-Git-Tag: php-7.1.2RC1~33^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e56fe7e5e7a926bfdf142a7a844544c0127e92b7;p=php Fix intermittent segfault in GD library The gdIOCtx struct should be zero filled with ecalloc. emalloc does not zero fill the struct. --- diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c index dd62c63664..388d66106e 100644 --- a/ext/gd/gd_ctx.c +++ b/ext/gd/gd_ctx.c @@ -152,7 +152,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, RETURN_FALSE; } } else { - ctx = emalloc(sizeof(gdIOCtx)); + ctx = ecalloc(1, sizeof(gdIOCtx)); ctx->putC = _php_image_output_putc; ctx->putBuf = _php_image_output_putbuf; ctx->gd_free = _php_image_output_ctxfree; @@ -165,7 +165,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, } if (!ctx) { - ctx = emalloc(sizeof(gdIOCtx)); + ctx = ecalloc(1, sizeof(gdIOCtx)); ctx->putC = _php_image_stream_putc; ctx->putBuf = _php_image_stream_putbuf; if (close_stream) {