[LLVMdev] [Patch] WinCOFFObjectWriter: fix for storing pointer to string table in header name field
Reid Kleckner
rnk at google.com
Tue Jul 23 09:55:10 PDT 2013
On Tue, Jul 23, 2013 at 12:48 PM, Nico Rieck <nico.rieck at gmail.com> wrote:
> On 23.07.2013 18:43, Reid Kleckner wrote:
>
>> Is there a problem if the string is not null terminated? If not, you can
>> snprintf it right into place instead of doing sprintf+mempcy.
>>
>
> snprintf always null-terminates (and truncates if there's not enough
> space).
Nuh uh: "The _snprintf function formats and stores count or fewer
characters in buffer, and appends a terminating null character if the
formatted string length is strictly less than count characters."
http://msdn.microsoft.com/en-us/library/2ts7cx93(v=vs.100).aspx
Please don't assume snprintf always null terminates.
This may be Windows-specific behavior that you shouldn't rely on. If
that's the case, ignore my suggestion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130723/bd7701ac/attachment.html>
More information about the llvm-dev
mailing list