How to unpack NULL string in libffi
Posted: Mon May 18, 2015 6:28 pm
`unpack` function with LIBFFI segfault when variable type "char*" is NULL.
I expected following behavior:
How to avoid something this?
(It can use `unpack` without LIBFFI. but code will be more complex.)
Code: Select all
struct string {
char *ptr;
size_t len;
};
Code: Select all
newLISP v.10.6.2 32-bit on Win32 IPv4/6 UTF-8 libffi, options: newlisp -h
> (struct '_struct_string "char*" "long")
_struct_string
> (setf s (pack _struct_string 0 0))
"\000\000\000\000\000\000\000\000"
> (unpack _struct_string s)
Segment fault
Code: Select all
> (unpack _struct_string s)
(nil 0)
(It can use `unpack` without LIBFFI. but code will be more complex.)