Closed vsergeev closed 4 years ago
the global array fix has incorrect semantics here, as any context where an array is returned should make a C++-style reference; __newindex
for cdata
already handles this specially, but there is in fact no need for any special handling, so I'll just fix it
Fixed 2884f11a1d07edeafc8e12c0deac55dd5904e5d2 , 2e8c378d33270ec647ad57f2b6067c6f2c74a29c
fix global array variables
the cdata object created for global arrays was dereferencing the library symbol instead of treating it as a pointer. this causes a segfault when the array is accessed by the user and dereferenced a second time.
I made this modification to the
to_lua()
code path, which is called fromget_global()
, but I'm not sure if code path is used in other contexts where a builtin array should be handled differently.fix ffi.string() for flexible arrays
ffi_module::string_f()
limits serialization of theC_BUILTIN_ARRAY
todecl.alloc_size()
length, which is 0 for flexible arrays and results in the empty string. this commit changes flexible arrays to be treated as null-terminated char pointers.