Skip to content

Commit 6cb75fb

Browse files
committed
Fix #70315: 500 Server Error but page is fully rendered
That happens because the external libgd uses other error codes than PHP (and the bundled libgd), but the libgd error codes are simply forwarded to php_verror(). We fix that by properly mapping libgd errors to PHP errors.
1 parent 8b905e3 commit 6cb75fb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ext/gd/gd.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ static void php_free_ps_enc(zend_rsrc_list_entry *rsrc TSRMLS_DC);
6969
#endif
7070

7171
#include <gd.h>
72+
#ifndef HAVE_GD_BUNDLED
73+
# include <gd_errors.h>
74+
#endif
7275
#include <gdfontt.h> /* 1 Tiny font */
7376
#include <gdfonts.h> /* 2 Small font */
7477
#include <gdfontmb.h> /* 3 Medium bold font */
@@ -1099,6 +1102,18 @@ void php_gd_error_method(int type, const char *format, va_list args)
10991102
{
11001103
TSRMLS_FETCH();
11011104

1105+
switch (type) {
1106+
case GD_DEBUG:
1107+
case GD_INFO:
1108+
case GD_NOTICE:
1109+
type = E_NOTICE;
1110+
break;
1111+
case GD_WARNING:
1112+
type = E_WARNING;
1113+
break;
1114+
default:
1115+
type = E_ERROR;
1116+
}
11021117
php_verror(NULL, "", type, format, args TSRMLS_CC);
11031118
}
11041119
/* }}} */

0 commit comments

Comments
 (0)