On Tue, Nov 19, 2013 at 11:06 AM, Yuras Shumovich <shumovichy@gmail.com> wrote:
IIRC, strlen doesn't count the terminating '\0', so you'll need to
malloc(strlen(*ascii) + 1).

Not sure why python works, maybe just different memory layout hides the
bug.

Also note that different memory allocators have different behaviors; depending on block size rounding, string length and arena accounting overhead, the allocated block may be larger than requested. So the malloc() that Python provides may possibly be returning something "accidentally" large enough to handle the NUL anyway. (I don't know if Python actually overrides/replaces the default malloc(); some other interpreters do.)

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net