Skip to content

Commit 93c3ebd

Browse files
authored
ext/gd minor corrections concerning image format id for errors. (#14887)
1 parent 9185f61 commit 93c3ebd

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

ext/gd/gd.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ static void php_image_filter_pixelate(INTERNAL_FUNCTION_PARAMETERS);
118118
static void php_image_filter_scatter(INTERNAL_FUNCTION_PARAMETERS);
119119

120120
/* End Section filters declarations */
121-
static gdImagePtr _php_image_create_from_string(zend_string *Data, char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr));
122-
static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr));
123-
static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn);
121+
static gdImagePtr _php_image_create_from_string(zend_string *Data, const char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr));
122+
static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, const char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr));
123+
static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, const char *tn);
124124
static gdIOCtx *create_stream_context(php_stream *stream, int close_stream);
125125
static gdIOCtx *create_output_context(zval *to_zval, uint32_t arg_num);
126126
static int _php_image_type(zend_string *data);
@@ -1424,7 +1424,7 @@ static int _php_image_type(zend_string *data)
14241424
/* }}} */
14251425

14261426
/* {{{ _php_image_create_from_string */
1427-
gdImagePtr _php_image_create_from_string(zend_string *data, char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr))
1427+
gdImagePtr _php_image_create_from_string(zend_string *data, const char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr))
14281428
{
14291429
gdImagePtr im;
14301430
gdIOCtx *io_ctx;
@@ -1529,7 +1529,7 @@ PHP_FUNCTION(imagecreatefromstring)
15291529
/* }}} */
15301530

15311531
/* {{{ _php_image_create_from */
1532-
static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr))
1532+
static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, const char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr))
15331533
{
15341534
char *file;
15351535
size_t file_len;
@@ -1759,7 +1759,7 @@ PHP_FUNCTION(imagecreatefromtga)
17591759
#endif
17601760

17611761
/* {{{ _php_image_output */
1762-
static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn)
1762+
static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, const char *tn)
17631763
{
17641764
zval *imgind;
17651765
char *file = NULL;
@@ -3001,8 +3001,7 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
30013001
{
30023002
zval *IM;
30033003
zend_long X, Y, COL;
3004-
char *C;
3005-
size_t C_len;
3004+
zend_string *C;
30063005
gdImagePtr im;
30073006
int ch = 0, col, x, y, i, l = 0;
30083007
unsigned char *str = NULL;
@@ -3014,7 +3013,7 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
30143013
Z_PARAM_OBJ_OF_CLASS_OR_LONG(font_obj, gd_font_ce, font_int)
30153014
Z_PARAM_LONG(X)
30163015
Z_PARAM_LONG(Y)
3017-
Z_PARAM_STRING(C, C_len)
3016+
Z_PARAM_STR(C)
30183017
Z_PARAM_LONG(COL)
30193018
ZEND_PARSE_PARAMETERS_END();
30203019

@@ -3023,9 +3022,9 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
30233022
col = COL;
30243023

30253024
if (mode < 2) {
3026-
ch = (int)((unsigned char)*C);
3025+
ch = (int)((unsigned char)*ZSTR_VAL(C));
30273026
} else {
3028-
str = (unsigned char *) estrndup(C, C_len);
3027+
str = (unsigned char *) estrndup(ZSTR_VAL(C), ZSTR_LEN(C));
30293028
l = strlen((char *)str);
30303029
}
30313030

@@ -3407,6 +3406,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode)
34073406

34083407
PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename");
34093408

3409+
// libgd note: Those should return const char * ideally, but backward compatibility ..
34103410
if (EXT) {
34113411
error = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex);
34123412
} else {

0 commit comments

Comments
 (0)