Skip to content

Commit c4727d1

Browse files
committed
stream: fix double error message creation
1 parent dfe0ea5 commit c4727d1

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

main/streams/stream_errors.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,25 @@ static void php_stream_store_error_common(php_stream_context *context, php_strea
289289
}
290290

291291
/* Wrapper error reporting - stores in FG(wrapper_stored_errors) */
292-
static void php_stream_wrapper_error_internal_with_name(const char *wrapper_name,
292+
static void php_stream_wrapper_error_internal_with_name_and_message(const char *wrapper_name,
293293
php_stream_context *context, const char *docref, int options, int severity, bool terminal,
294-
int code, char *param, const char *fmt, va_list args)
294+
int code, char *param, zend_string *message)
295295
{
296-
zend_string *message = vstrpprintf(0, fmt, args);
297-
298296
php_stream_process_error(context, wrapper_name, NULL, docref, code, ZSTR_VAL(message), param,
299297
severity, terminal);
300298

301299
php_stream_store_error_common(
302300
context, NULL, message, docref, code, wrapper_name, param, severity, terminal);
301+
}
302+
303+
static void php_stream_wrapper_error_internal_with_name(const char *wrapper_name,
304+
php_stream_context *context, const char *docref, int options, int severity, bool terminal,
305+
int code, char *param, const char *fmt, va_list args)
306+
{
307+
zend_string *message = vstrpprintf(0, fmt, args);
308+
309+
php_stream_wrapper_error_internal_with_name_and_message(
310+
wrapper_name, context, docref, options, severity, terminal, code, param, message);
303311

304312
zend_string_release(message);
305313
}
@@ -420,8 +428,8 @@ static void php_stream_wrapper_log_error_internal(const php_stream_wrapper *wrap
420428

421429
if (options & REPORT_ERRORS) {
422430
/* Report immediately using standard error functions */
423-
php_stream_wrapper_error_internal_with_name(
424-
wrapper_name, context, NULL, options, severity, terminal, code, param, fmt, args);
431+
php_stream_wrapper_error_internal_with_name_and_message(
432+
wrapper_name, context, NULL, options, severity, terminal, code, param, message);
425433
} else {
426434
/* Store for later display in FG(wrapper_logged_errors) */
427435
php_stream_wrapper_log_store_error(message, code, wrapper_name, param, severity, terminal);
@@ -533,7 +541,7 @@ PHPAPI void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper,
533541
{
534542
if (wrapper) {
535543
const char *wrapper_name = PHP_STREAM_ERROR_WRAPPER_NAME(wrapper);
536-
php_stream_display_wrapper_errors(wrapper_name, context, code, path, caption);
544+
php_stream_display_wrapper_name_errors(wrapper_name, context, code, path, caption);
537545
}
538546
}
539547

0 commit comments

Comments
 (0)