[PATCH] libs/wine/string.c: Duplicate Windows behaviour in vsnprintfW
jnvsor at gmail.com
Thu Dec 18 11:09:01 CST 2014
> If buffer or format is NULL, or if count is less than or equal to zero, these functions invoke the invalid parameter handler, as described in Parameter Validation. If execution is allowed to continue, these functions return -1 and set errno to EINVAL.
This doc says that vsnprintf *should* always return -1 given your example.
Is there a test that shows the MSDN docs are wrong?
On 12/18/2014 11:57 AM, Hugh McMaster wrote:
> Recent discussions on the wine-devel mailing list conclude that Wine's vsnprintfW must duplicate Windows' vsnprintf behaviourW.
> Currently, there are two issues.
> 1. vsnprintfW(NULL, 0, fmt, args). Both Windows and GCC allow these arguments. Both return the number of chars that would be written in this instance. Wine returns -1, which is incorrect.
> 2. vsnprintfW(some buffer, 0, fmt, args). Both Windows and Wine return -1, but in this case, Wine does this by default. We need to maintain this behaviour.
> To fix these inconsistencies, we need to add an 'else' block to the check for len (i.e. checking for a non-zero value). Then we check for a NULL pointer. If true, we return (int)written, like Windows and GCC do, because vsnprintfW(NULL, 0, fmt, args) was called.
> This patch fixes these issues.
>  https://www.winehq.org/pipermail/wine-devel/2014-December/106066.html
More information about the wine-patches