Re: cvs: php4 /main main.c
| From: | Sascha Schumann | Date: | Thu, 31 Aug 2000 19:34:43 +0000 |
| Subject: | Re: cvs: php4 /main main.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-1475@lists.php.net to get a copy of this message | ||
> (the older code worked, even though it didn't compile well
> for some very odd reason, probably a compiler bug;
The type of va_list is implementation-dependent. Not
supporting GCC's copy-struct-by-assignment extension is
hardly a bug.
> @@ -366,7 +366,6 @@
> /* get include file name */
> if (PG(log_errors) || PG(display_errors) || (!module_initialized)) {
> size = vsnprintf(buffer, sizeof(buffer) - 1, format, orig_args);
> - va_end(orig_args);
>
> buffer[sizeof(buffer) - 1] = 0;
>
> @@ -442,7 +441,6 @@
> pval *tmp;
>
> size = vsnprintf(buffer, sizeof(buffer) - 1, format, orig_args);
> - va_end(orig_args);
>
> buffer[sizeof(buffer) - 1] = 0;
While this change might fix things on some platforms, it is
incorrect.
vsnprintf() will apply va_arg to orig_args which in turn
renders orig_args unuseable for the calling function. The
problem here is that there is no real portable way to use
va_list twice in a function which the va_list was passed to
(you can reinitialize a va_list as often as you want, if you
have access to argN, i.e. in the calling function).
The simplest solution here seems to have a flag for the
buffer and to create it once, even if it is needed twice.
- Sascha