Skip to content

Commit 91e9210

Browse files
committed
fix leaks
1 parent 1bdcfd6 commit 91e9210

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ext/gd/gd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4115,6 +4115,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
41154115
case PHP_GDIMG_TYPE_WEBP:
41164116
if (quality < -1) {
41174117
zend_argument_value_error(3, "must be at least -1");
4118+
ctx->gd_free(ctx);
41184119
RETURN_THROWS();
41194120
} else if (quality == -1) {
41204121
quality = 80;
@@ -4126,10 +4127,12 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
41264127
case PHP_GDIMG_TYPE_AVIF:
41274128
if (quality < -1 || quality > 100) {
41284129
zend_argument_value_error(3, "must be between -1 and 100");
4130+
ctx->gd_free(ctx);
41294131
RETURN_THROWS();
41304132
}
41314133
if (speed < -1 || speed > 10) {
41324134
zend_argument_value_error(4, "must be between -1 and 10");
4135+
ctx->gd_free(ctx);
41334136
RETURN_THROWS();
41344137
} else if (speed == -1) {
41354138
speed = 6;
@@ -4141,6 +4144,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
41414144
case PHP_GDIMG_TYPE_PNG:
41424145
if (quality < -1 || quality > 9) {
41434146
zend_argument_value_error(3, "must be between -1 and 9");
4147+
ctx->gd_free(ctx);
41444148
RETURN_THROWS();
41454149
}
41464150
#ifdef HAVE_GD_BUNDLED

0 commit comments

Comments
 (0)