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.
This commit is contained in:
Niels 2023-01-08 12:09:20 +01:00 committed by GitHub
parent 5f42a46405
commit 58d741c042
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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) {