]> granicus.if.org Git - php/commitdiff
Fix intermittent segfault in GD library
authorMitch Hagstrand <mhagstrand@gmail.com>
Sat, 21 Jan 2017 20:40:15 +0000 (12:40 -0800)
committerJoe Watkins <krakjoe@php.net>
Sun, 22 Jan 2017 06:40:55 +0000 (06:40 +0000)
The gdIOCtx struct should be zero filled with ecalloc.
emalloc does not zero fill the struct.

ext/gd/gd_ctx.c

index dd62c636648ea33d2f401f129f0ccc7a7c5dae6e..388d66106e9e3715f1390f31948ca28ec01e6d64 100644 (file)
@@ -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) {