Pass zend_string message to zend_error_cb

This makes the zend_error_cb API simpler, and avoid formatting
the same message in multiple places.

It should be noted that the passed zend_string is always
non-persistent, so if you want to store it persistently somewhere,
you may still need to duplicate it.

The last_error_message is cleared a bit more aggressive, to make
sure it doesn't hang around across allocator life-cycles.

Closes GH-5639.
This commit is contained in:
Nikita Popov 2020-05-29 10:33:22 +02:00
parent e949f306be
commit 975acfe71e
10 changed files with 119 additions and 162 deletions

View file

@ -1214,7 +1214,8 @@ static void php_cli_server_log_response(php_cli_server_client *client, int statu
/* error */
if (append_error_message) {
spprintf(&error_buf, 0, " - %s in %s on line %d", PG(last_error_message), PG(last_error_file), PG(last_error_lineno));
spprintf(&error_buf, 0, " - %s in %s on line %d",
ZSTR_VAL(PG(last_error_message)), PG(last_error_file), PG(last_error_lineno));
if (!error_buf) {
efree(basic_buf);
if (message) {