Barry A. Warsaw wrote: > TP> 20 bytes isn't enough to hold the result on a 64-bit box > TP> (insert rant about the idiot practice of trying to make stack > TP> buffers as small as possible). You have 20 characters in your > TP> result, but need 21 to hold the trailing 0 byte too. I don't > TP> know what snprintf does when there's not enough room, but I > TP> think you just showed us what it does on Tru64 <wink>. > > Heh, I was going to suggest that this might be a good place to > substitute a call to PyString_FromFormat*() but then I read this > little nugget: > > case 'd': case 'i': case 'x': > (void) va_arg(count, int); > /* 20 bytes should be enough to hold a 64-bit > integer */ > n += 20; > break; The size calculated by PyString_FromFormat is used to allocate a Python string, not a C string. The Python string allocator always adds an extra 0 byte at the end. (if it hadn't, I would have used 21 instead) </F>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4