Skip to content

Commit 9c8d288

Browse files
committed
Fix date error messages for embedded NUL bytes
1 parent 1a48f90 commit 9c8d288

12 files changed

Lines changed: 242 additions & 82 deletions

Zend/zend.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,6 @@ ZEND_API void zend_free_recorded_errors(void)
18151815
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format, ...) /* {{{ */
18161816
{
18171817
va_list va;
1818-
char *message = NULL;
18191818

18201819
if (!exception_ce) {
18211820
exception_ce = zend_ce_error;
@@ -1827,13 +1826,13 @@ ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const c
18271826
}
18281827

18291828
va_start(va, format);
1830-
zend_vspprintf(&message, 0, format, va);
1831-
1829+
zend_string *message = zend_vstrpprintf(0, format, va);
18321830
//TODO: we can't convert compile-time errors to exceptions yet???
18331831
if (EG(current_execute_data) && !CG(in_compilation)) {
1834-
zend_throw_exception(exception_ce, message, 0);
1832+
const char *format = "%S";
1833+
zend_throw_exception_ex(exception_ce, 0, format, message);
18351834
} else {
1836-
zend_error_noreturn(E_ERROR, "%s", message);
1835+
zend_error_noreturn(E_ERROR, "%s", ZSTR_VAL(message));
18371836
}
18381837

18391838
efree(message);

0 commit comments

Comments
 (0)