bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3] Fix reuse of va_list object in while loop in _nc_printf_s


From: Thomas Dickey
Subject: Re: [PATCH v3] Fix reuse of va_list object in while loop in _nc_printf_string_sp()
Date: Wed, 27 Sep 2023 18:10:13 -0400

On Wed, Sep 27, 2023 at 06:09:50PM +0100, Ian Abbott wrote:
> When `#if USE_SAFE_SPRINTF` is false and `#if HAVE_VSNPRINTF` is true,
> `vsnprintf()` is called in a `while` loop that reallocates the
> `my_buffer` if the buffer is too small to hold the output.
> 
> The `va_list ap` parameter value becomes indeterminate after the first
> call to `vsnprintf()` leading to undefined behavior on the next
> iteration of the loop.  Make a fresh copy of the `va_list ap` parameter
> into new variable `va_list ap2` and pass the copy to `vsnprintf()`.

thanks

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]