Re: [RFC] Time to talk about StringNG merge again?

From: Kinkie <gkinkie_at_gmail.com>
Date: Thu, 1 Aug 2013 11:08:31 +0200

> Another small bug in that code is that arguments or even fmt might
> actually end with a valid \0 byte that should be appended and counted
> (not a c-string terminating byte).
>
> This check should be done once, with controlled fmt and arguments so
> that we can detect problems reliably. You can do that at module
> initialization time, for example (./configure might be too early because
> libraries might change) and set a static SnprintfCountsTerminator
> variable accordingly.
>
> char buf[16];
> SprintfCountsTerminator = snprintf(buf, sizeof(buf), "%s", "1") == 2;

Clever!
Done.

-- 
    /kinkie
Received on Thu Aug 01 2013 - 09:08:39 MDT

This archive was generated by hypermail 2.2.0 : Thu Aug 01 2013 - 12:00:51 MDT