Skip to content

Commit

Permalink
backport 9a07245 from 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling committed Jan 11, 2016
1 parent 35e87c0 commit fffbca5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
19 changes: 16 additions & 3 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions tests/basic/bug71273.phpt
Original file line number Diff line number Diff line change
@@ -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==

0 comments on commit fffbca5

Please sign in to comment.