diff options
author | Sascha Schumann <sas@php.net> | 2000-09-01 09:54:32 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2000-09-01 09:54:32 +0000 |
commit | df273c9d01b165fec834d93bdbf81176dbb73248 (patch) | |
tree | 29f94523c4da3dc9edd6eda8242921360c2e2ad1 /main | |
parent | d60799bf6b5e79fc43054c07f6ba3cddbdaa1066 (diff) | |
download | php-git-df273c9d01b165fec834d93bdbf81176dbb73248.tar.gz |
Hopefully last round of fixing varargs use.
We don't need to create the log message twice, and by doing it only
once we also avoid the orig_args trap.
Diffstat (limited to 'main')
-rw-r--r-- | main/main.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/main/main.c b/main/main.c index e7626e81a8..49aa8891c0 100644 --- a/main/main.c +++ b/main/main.c @@ -329,6 +329,7 @@ PHPAPI int php_printf(const char *format, ...) static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list orig_args) { char buffer[1024]; + zend_bool buffer_ok = 0; int size = 0; ELS_FETCH(); PLS_FETCH(); @@ -366,6 +367,8 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ /* get include file name */ if (PG(log_errors) || PG(display_errors) || (!module_initialized)) { size = vsnprintf(buffer, sizeof(buffer) - 1, format, orig_args); + buffer_ok = 1; + va_end(orig_args); buffer[sizeof(buffer) - 1] = 0; @@ -440,9 +443,11 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ if (PG(track_errors) && EG(active_symbol_table)) { pval *tmp; - size = vsnprintf(buffer, sizeof(buffer) - 1, format, orig_args); - - buffer[sizeof(buffer) - 1] = 0; + if (!buffer_ok) { + size = vsnprintf(buffer, sizeof(buffer) - 1, format, orig_args); + buffer[sizeof(buffer) - 1] = 0; + va_end(orig_args); + } ALLOC_ZVAL(tmp); INIT_PZVAL(tmp); |