summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/main.c19
-rw-r--r--tests/basic/bug71273.phpt21
2 files changed, 37 insertions, 3 deletions
diff --git a/main/main.c b/main/main.c
index cc21fbd539..877507d8b8 100644
--- a/main/main.c
+++ b/main/main.c
@@ -788,9 +788,20 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
if (PG(html_errors)) {
size_t len;
char *replace = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC);
+
+ if (!replace || len < 1) {
+ replace = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, NULL TSRMLS_CC);
+ }
+
efree(buffer);
- buffer = replace;
- buffer_len = len;
+
+ if (replace) {
+ buffer = replace;
+ buffer_len = len;
+ } else {
+ buffer = "";
+ buffer_len = 0;
+ }
}
/* which function caused the problem if any at all */
@@ -935,7 +946,9 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) &tmp, sizeof(zval *), NULL);
}
}
- str_efree(buffer);
+ if (buffer_len > 0) {
+ str_efree(buffer);
+ }
php_error(type, "%s", message);
efree(message);
diff --git a/tests/basic/bug71273.phpt b/tests/basic/bug71273.phpt
new file mode 100644
index 0000000000..d0cd72577e
--- /dev/null
+++ b/tests/basic/bug71273.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #71273 A wrong ext directory setup in php.ini leads to crash
+--SKIPIF--
+<?php
+ if ("cli" != php_sapi_name()) {
+ die("skip CLI only");
+ }
+?>
+--FILE--
+<?php
+ /* NOTE this file is required to be encoded in iso-8859-1 */
+
+ $cmd = getenv('TEST_PHP_EXECUTABLE') . " -n -d html_errors=on -d extension_dir=a/é/w -d extension=php_kartoffelbrei.dll -v 2>&1";
+ $out = shell_exec($cmd);
+
+ var_dump(preg_match(",.+a[\\/].+[\\/]w.php_kartoffelbrei.dll.+,s", $out));
+?>
+==DONE==
+--EXPECTF--
+int(1)
+==DONE==