|
On 08.11.2011 11:30, Daurnimator wrote:
See http://luajit.org/ext_ffi_semantics.html#initByte arrays may also be initialized with a Lua string. This copies thewhole string plus a terminating zero-byte. The copy stops early only if the array has a known, fixed size.I guess a VLA (A variable-length array) is not of a known, fixed size.(though I guess it should be.....)
My reasoning is: I'm using nelem (http://luajit.org/ext_ffi_api.html#ffi_new) to copy a string that represents raw bytes (and has no reason to be \0-terminated). It should behave approximately like strncpy(). But what I find the most strange is that the segfault doesn't happen at that line, it happens later when the memory is garbage collected. -- Pierre Chapuis