Skip to content

Commit 2796160

Browse files
committed
Better critical error handling (fix for previous html encoding patch).
1 parent 0e46f51 commit 2796160

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

main/main.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,12 +770,14 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
770770
char *append_string = INI_STR("error_append_string");
771771

772772
if (PG(html_errors)) {
773-
char *buf, *buf2;
774-
int len2, len = spprintf(&buf, 0, "%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
775-
buf2 = php_escape_html_entities(buf, len, &len2, 0, ENT_COMPAT, NULL TSRMLS_CC);
776-
php_printf("%s", buf2);
777-
efree(buf);
778-
efree(buf2);
773+
if (type == E_ERROR) {
774+
int len;
775+
char *buf = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC);
776+
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buf, error_filename, error_lineno, STR_PRINT(append_string));
777+
efree(buf);
778+
} else {
779+
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
780+
}
779781
} else {
780782
php_printf("%s\n%s: %s in %s on line %d\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
781783
}

0 commit comments

Comments
 (0)