Skip to content

Commit e56fe7e

Browse files
mhagstrandkrakjoe
authored andcommitted
Fix intermittent segfault in GD library
The gdIOCtx struct should be zero filled with ecalloc. emalloc does not zero fill the struct.
1 parent 42d53f3 commit e56fe7e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/gd/gd_ctx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
152152
RETURN_FALSE;
153153
}
154154
} else {
155-
ctx = emalloc(sizeof(gdIOCtx));
155+
ctx = ecalloc(1, sizeof(gdIOCtx));
156156
ctx->putC = _php_image_output_putc;
157157
ctx->putBuf = _php_image_output_putbuf;
158158
ctx->gd_free = _php_image_output_ctxfree;
@@ -165,7 +165,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
165165
}
166166

167167
if (!ctx) {
168-
ctx = emalloc(sizeof(gdIOCtx));
168+
ctx = ecalloc(1, sizeof(gdIOCtx));
169169
ctx->putC = _php_image_stream_putc;
170170
ctx->putBuf = _php_image_stream_putbuf;
171171
if (close_stream) {

0 commit comments

Comments
 (0)