Skip to content

Commit 58d741c

Browse files
authored
Remove unnecessary NULL-checks on ctx (#10256)
ctx can never be zero in these functions because they are dispatched virtually by looking up their entries in ctx. Furthermore, 2 of these checks never actually worked because ctx was dereferenced before ctx was NULL-checked.
1 parent 5f42a46 commit 58d741c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

ext/gd/gd.c

+3-10
Original file line numberDiff line numberDiff line change
@@ -3987,9 +3987,7 @@ static int _php_image_output_putbuf(struct gdIOCtx *ctx, const void* buf, int l)
39873987

39883988
static void _php_image_output_ctxfree(struct gdIOCtx *ctx) /* {{{ */
39893989
{
3990-
if(ctx) {
3991-
efree(ctx);
3992-
}
3990+
efree(ctx);
39933991
} /* }}} */
39943992

39953993
static void _php_image_stream_putc(struct gdIOCtx *ctx, int c) /* {{{ */ {
@@ -4009,21 +4007,16 @@ static void _php_image_stream_ctxfree(struct gdIOCtx *ctx) /* {{{ */
40094007
if(ctx->data) {
40104008
ctx->data = NULL;
40114009
}
4012-
if(ctx) {
4013-
efree(ctx);
4014-
}
4010+
efree(ctx);
40154011
} /* }}} */
40164012

40174013
static void _php_image_stream_ctxfreeandclose(struct gdIOCtx *ctx) /* {{{ */
40184014
{
4019-
40204015
if(ctx->data) {
40214016
php_stream_close((php_stream *) ctx->data);
40224017
ctx->data = NULL;
40234018
}
4024-
if(ctx) {
4025-
efree(ctx);
4026-
}
4019+
efree(ctx);
40274020
} /* }}} */
40284021

40294022
static gdIOCtx *create_stream_context_from_zval(zval *to_zval) {

0 commit comments

Comments
 (0)