Skip to content

Commit d20f826

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix detection of image formats in system gd library
2 parents 3ab7aa0 + f732ab8 commit d20f826

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ PHP NEWS
2020
. Fixed bug #75712 (getenv in php-fpm should not read $_ENV, $_SERVER).
2121
(Jakub Zelenka)
2222

23+
- GD:
24+
. Fixed bug GH-12019 (detection of image formats in system gd library).
25+
(Michael Orlitzky)
26+
2327
- MySQLnd:
2428
. Fixed bug GH-11950 ([mysqlnd] Fixed not to set CR_MALFORMED_PACKET to error
2529
if CR_SERVER_GONE_ERROR is already set). (Saki Takamachi)

ext/gd/config.m4

+53-8
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,60 @@ AC_DEFUN([PHP_GD_JISX0208],[
138138
fi
139139
])
140140

141+
dnl Build and run a program to determine if GD has support for the given
142+
dnl format. The first argument is the proper-noun-capitalized name of the
143+
dnl format -- basically the word Foo in gdImageCreateFromFoo -- such as
144+
dnl Png. If support for format Foo exists, the second argument (the name
145+
dnl of a constant) will be defined to 1. The reason for this charade is
146+
dnl that gd defines "junk" versions of each gdImageCreateFromFoo function
147+
dnl even when it does not support the Foo format. Those junk functions
148+
dnl display a warning but eventually return normally, making a simple link
149+
dnl or run test insufficient.
150+
AC_DEFUN([PHP_GD_CHECK_FORMAT],[
151+
old_LIBS="${LIBS}"
152+
LIBS="${LIBS} ${GD_SHARED_LIBADD}"
153+
AC_MSG_CHECKING([for working gdImageCreateFrom$1 in libgd])
154+
AC_LANG_PUSH([C])
155+
AC_RUN_IFELSE([AC_LANG_SOURCE([
156+
#include <stdio.h>
157+
#include <unistd.h>
158+
#include <gd.h>
159+
160+
/* A custom gdErrorMethod */
161+
void exit1(int priority, const char *format, va_list args) {
162+
_exit(1);
163+
}
164+
165+
/* Override the default gd_error_method with one that
166+
actually causes the program to return an error. */
167+
int main(int argc, char** argv) {
168+
m4_if([$1],[Xpm],
169+
[char* f = "test.xpm"],
170+
[FILE* f = NULL]);
171+
gdSetErrorMethod(exit1);
172+
gdImagePtr p = gdImageCreateFrom$1(f);
173+
return 0;
174+
}])],[
175+
AC_MSG_RESULT([yes])
176+
AC_DEFINE($2, 1, [Does gdImageCreateFrom$1 work?])
177+
],[
178+
AC_MSG_RESULT([no])
179+
],[
180+
AC_MSG_RESULT([no])
181+
])
182+
AC_LANG_POP([C])
183+
LIBS="${old_LIBS}"
184+
])
185+
141186
AC_DEFUN([PHP_GD_CHECK_VERSION],[
142-
PHP_CHECK_LIBRARY(gd, gdImageCreateFromPng, [AC_DEFINE(HAVE_GD_PNG, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
143-
PHP_CHECK_LIBRARY(gd, gdImageCreateFromAvif, [AC_DEFINE(HAVE_GD_AVIF, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
144-
PHP_CHECK_LIBRARY(gd, gdImageCreateFromWebp, [AC_DEFINE(HAVE_GD_WEBP, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
145-
PHP_CHECK_LIBRARY(gd, gdImageCreateFromJpeg, [AC_DEFINE(HAVE_GD_JPG, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
146-
PHP_CHECK_LIBRARY(gd, gdImageCreateFromXpm, [AC_DEFINE(HAVE_GD_XPM, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
147-
PHP_CHECK_LIBRARY(gd, gdImageCreateFromBmp, [AC_DEFINE(HAVE_GD_BMP, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
148-
PHP_CHECK_LIBRARY(gd, gdImageCreateFromTga, [AC_DEFINE(HAVE_GD_TGA, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
149-
PHP_CHECK_LIBRARY(gd, gdImageStringFT, [AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
187+
PHP_GD_CHECK_FORMAT([Png], [HAVE_GD_PNG])
188+
PHP_GD_CHECK_FORMAT([Avif], [HAVE_GD_AVIF])
189+
PHP_GD_CHECK_FORMAT([Webp], [HAVE_GD_WEBP])
190+
PHP_GD_CHECK_FORMAT([Jpeg], [HAVE_GD_JPG])
191+
PHP_GD_CHECK_FORMAT([Xpm], [HAVE_GD_XPM])
192+
PHP_GD_CHECK_FORMAT([Bmp], [HAVE_GD_BMP])
193+
PHP_GD_CHECK_FORMAT([Tga], [HAVE_GD_TGA])
194+
PHP_CHECK_LIBRARY(gd, gdFontCacheShutdown, [AC_DEFINE(HAVE_GD_FREETYPE, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
150195
PHP_CHECK_LIBRARY(gd, gdVersionString, [AC_DEFINE(HAVE_GD_LIBVERSION, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
151196
PHP_CHECK_LIBRARY(gd, gdImageGetInterpolationMethod, [AC_DEFINE(HAVE_GD_GET_INTERPOLATION, 1, [ ])], [], [ $GD_SHARED_LIBADD ])
152197
])

0 commit comments

Comments
 (0)