From 58d741c0425839997c8cc9829d28111df817725f Mon Sep 17 00:00:00 2001 From: Niels <7771979+nielsdos@users.noreply.github.com> Date: Sun, 8 Jan 2023 12:09:20 +0100 Subject: [PATCH] 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. --- ext/gd/gd.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 227698f92ba..47090c04c34 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -3987,9 +3987,7 @@ static int _php_image_output_putbuf(struct gdIOCtx *ctx, const void* buf, int l) static void _php_image_output_ctxfree(struct gdIOCtx *ctx) /* {{{ */ { - if(ctx) { - efree(ctx); - } + efree(ctx); } /* }}} */ static void _php_image_stream_putc(struct gdIOCtx *ctx, int c) /* {{{ */ { @@ -4009,21 +4007,16 @@ static void _php_image_stream_ctxfree(struct gdIOCtx *ctx) /* {{{ */ if(ctx->data) { ctx->data = NULL; } - if(ctx) { - efree(ctx); - } + efree(ctx); } /* }}} */ static void _php_image_stream_ctxfreeandclose(struct gdIOCtx *ctx) /* {{{ */ { - if(ctx->data) { php_stream_close((php_stream *) ctx->data); ctx->data = NULL; } - if(ctx) { - efree(ctx); - } + efree(ctx); } /* }}} */ static gdIOCtx *create_stream_context_from_zval(zval *to_zval) {