From e56fe7e5e7a926bfdf142a7a844544c0127e92b7 Mon Sep 17 00:00:00 2001 From: Mitch Hagstrand Date: Sat, 21 Jan 2017 12:40:15 -0800 Subject: [PATCH] Fix intermittent segfault in GD library The gdIOCtx struct should be zero filled with ecalloc. emalloc does not zero fill the struct. --- ext/gd/gd_ctx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c index dd62c636648..388d66106e9 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) {