cvs: php4 /main main.c

From: Date: Fri, 01 Sep 2000 09:54:32 +0000
Subject: cvs: php4 /main main.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1483@lists.php.net to get a copy of this message
sas Fri Sep 1 02:54:32 2000 EDT Modified files: /php4/main main.c Log: 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. Index: php4/main/main.c diff -u php4/main/main.c:1.308 php4/main/main.c:1.309 --- php4/main/main.c:1.308 Thu Aug 31 09:15:31 2000 +++ php4/main/main.c Fri Sep 1 02:54:32 2000 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.308 2000/08/31 16:15:31 stas Exp $ */ +/* $Id: main.c,v 1.309 2000/09/01 09:54:32 sas Exp $ */ #include <stdio.h> @@ -329,6 +329,7 @@ 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 @@ /* 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 @@ 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);

« previous php.cvs (#1483) next »