<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 19, 2013 at 11:06 AM, Yuras Shumovich <span dir="ltr"><<a href="mailto:shumovichy@gmail.com" target="_blank">shumovichy@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">IIRC, strlen doesn't count the terminating '\0', so you'll need to<br>
malloc(strlen(*ascii) + 1).<br>
<br>
Not sure why python works, maybe just different memory layout hides the<br>
bug.<br></blockquote><div><br></div><div>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.)</div>
<div><br></div></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>
<div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</div></div>