Skip to content

Commit

Permalink
ext/gd minor corrections concerning image format id for errors. (php#…
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored Jul 9, 2024
1 parent 9185f61 commit 93c3ebd
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ static void php_image_filter_pixelate(INTERNAL_FUNCTION_PARAMETERS);
static void php_image_filter_scatter(INTERNAL_FUNCTION_PARAMETERS);

/* End Section filters declarations */
static gdImagePtr _php_image_create_from_string(zend_string *Data, char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr));
static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr));
static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn);
static gdImagePtr _php_image_create_from_string(zend_string *Data, const char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr));
static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, const char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr));
static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, const char *tn);
static gdIOCtx *create_stream_context(php_stream *stream, int close_stream);
static gdIOCtx *create_output_context(zval *to_zval, uint32_t arg_num);
static int _php_image_type(zend_string *data);
Expand Down Expand Up @@ -1424,7 +1424,7 @@ static int _php_image_type(zend_string *data)
/* }}} */

/* {{{ _php_image_create_from_string */
gdImagePtr _php_image_create_from_string(zend_string *data, char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr))
gdImagePtr _php_image_create_from_string(zend_string *data, const char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr))
{
gdImagePtr im;
gdIOCtx *io_ctx;
Expand Down Expand Up @@ -1529,7 +1529,7 @@ PHP_FUNCTION(imagecreatefromstring)
/* }}} */

/* {{{ _php_image_create_from */
static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr))
static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, const char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr))
{
char *file;
size_t file_len;
Expand Down Expand Up @@ -1759,7 +1759,7 @@ PHP_FUNCTION(imagecreatefromtga)
#endif

/* {{{ _php_image_output */
static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn)
static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, const char *tn)
{
zval *imgind;
char *file = NULL;
Expand Down Expand Up @@ -3001,8 +3001,7 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
zval *IM;
zend_long X, Y, COL;
char *C;
size_t C_len;
zend_string *C;
gdImagePtr im;
int ch = 0, col, x, y, i, l = 0;
unsigned char *str = NULL;
Expand All @@ -3014,7 +3013,7 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
Z_PARAM_OBJ_OF_CLASS_OR_LONG(font_obj, gd_font_ce, font_int)
Z_PARAM_LONG(X)
Z_PARAM_LONG(Y)
Z_PARAM_STRING(C, C_len)
Z_PARAM_STR(C)
Z_PARAM_LONG(COL)
ZEND_PARSE_PARAMETERS_END();

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

if (mode < 2) {
ch = (int)((unsigned char)*C);
ch = (int)((unsigned char)*ZSTR_VAL(C));
} else {
str = (unsigned char *) estrndup(C, C_len);
str = (unsigned char *) estrndup(ZSTR_VAL(C), ZSTR_LEN(C));
l = strlen((char *)str);
}

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

PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename");

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

0 comments on commit 93c3ebd

Please sign in to comment.