mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
ext/gd: Fix GH-13082
Issue occur when compiling with recent clang releases (> 13) and with the '-Os' optimisation level, after using `imageloadfont` which returns a proper GdFont class leads to a subtle bug when attempting to use via the imagefont* function.
This commit is contained in:
parent
6339938c7e
commit
1e464e5b55
4 changed files with 24 additions and 4 deletions
4
NEWS
4
NEWS
|
@ -25,6 +25,10 @@ PHP NEWS
|
||||||
(Jakub Zelenka)
|
(Jakub Zelenka)
|
||||||
. Fixed bug GH-12905 (FFI::new interacts badly with observers). (nielsdos)
|
. Fixed bug GH-12905 (FFI::new interacts badly with observers). (nielsdos)
|
||||||
|
|
||||||
|
- GD:
|
||||||
|
. Fixed GH-13082 undefined behavior with GdFont instances handling with
|
||||||
|
imageload* and imagechar*. (David Carlier)
|
||||||
|
|
||||||
- Intl:
|
- Intl:
|
||||||
. Fixed GH-12943 (IntlDateFormatter::__construct accepts 'C' as valid locale).
|
. Fixed GH-12943 (IntlDateFormatter::__construct accepts 'C' as valid locale).
|
||||||
(David Carlier)
|
(David Carlier)
|
||||||
|
|
|
@ -2681,8 +2681,8 @@ static gdFontPtr php_find_gd_font(zend_object *font_obj, zend_long font_int)
|
||||||
*/
|
*/
|
||||||
static void php_imagefontsize(INTERNAL_FUNCTION_PARAMETERS, int arg)
|
static void php_imagefontsize(INTERNAL_FUNCTION_PARAMETERS, int arg)
|
||||||
{
|
{
|
||||||
zend_object *font_obj;
|
zend_object *font_obj = NULL;
|
||||||
zend_long font_int;
|
zend_long font_int = 0;
|
||||||
gdFontPtr font;
|
gdFontPtr font;
|
||||||
|
|
||||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||||
|
@ -2750,8 +2750,8 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
|
||||||
int ch = 0, col, x, y, i, l = 0;
|
int ch = 0, col, x, y, i, l = 0;
|
||||||
unsigned char *str = NULL;
|
unsigned char *str = NULL;
|
||||||
zend_object *font_obj;
|
zend_object *font_obj;
|
||||||
zend_long font_int;
|
zend_long font_int = 0;
|
||||||
gdFontPtr font;
|
gdFontPtr font = NULL;
|
||||||
|
|
||||||
ZEND_PARSE_PARAMETERS_START(6, 6)
|
ZEND_PARSE_PARAMETERS_START(6, 6)
|
||||||
Z_PARAM_OBJECT_OF_CLASS(IM, gd_image_ce)
|
Z_PARAM_OBJECT_OF_CLASS(IM, gd_image_ce)
|
||||||
|
|
BIN
ext/gd/tests/gh13082.gdf
Normal file
BIN
ext/gd/tests/gh13082.gdf
Normal file
Binary file not shown.
16
ext/gd/tests/gh13082.phpt
Normal file
16
ext/gd/tests/gh13082.phpt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
--TEST--
|
||||||
|
GH-13082 - imagefontwidth/height unexpectedly throwing an exception on a valid GdFont object.
|
||||||
|
--EXTENSIONS--
|
||||||
|
gd
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$font = imageloadfont(__DIR__ . "/gh13082.gdf");
|
||||||
|
if ($font === false) die("imageloadfont failed");
|
||||||
|
if (!($font instanceof GdFont)) die("invalid gd font");
|
||||||
|
|
||||||
|
var_dump(imagefontwidth($font));
|
||||||
|
var_dump(imagefontheight($font));
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
int(12)
|
||||||
|
int(20)
|
Loading…
Add table
Add a link
Reference in a new issue