tomaka / hlua

Rust library to interface with Lua
MIT License
507 stars 48 forks source link

Fixed segfault when deref unaligned typeid #220

Closed vallentin closed 3 months ago

vallentin commented 3 months ago

Fixed #219.

So I went on a bit of a journey in the #219 issue.

In conclusion, the address returned by ffi::lua_newuserdata() might be unaligned, which causes dereferencing actual_typeid to segfault due to a potential unaligned pointer. Changing it to allow for unaligned reads, results in all tests and all examples succeeding without segfaulting.

I'm unsure if the subsequent *data can ever be unaligned. But I didn't run into it so far.