Guard against most egregious mistakes in calling the library
LuaJIT FFI is not inherently memory safe and there is no way to completely guard against the caller doing something that will trample over memory, but we can get pretty close. Biggest issue is that an empty table will stand-in for a ref struct with a null ref. So check for that in all the calls. In the calls that raise errors we now have a specific error for it. In the other functions the "nil" object is handled quietly but without a nullptr dereference and hopefully no UB.
This commit is contained in:
@@ -11,7 +11,7 @@ Cassowary constraint solving is a technique that is particularly well suited to
|
||||
|
||||
There are a few Lua implementations or attempts. The SILE typesetting system has a pure Lua implementation of the original Cassowary code, which appears to be correct but is quite slow. There are two extant Lua ports of Kiwi, one that is based on a C rewrite of Kiwi. However testing of these was not encouraging with either segfaults or incorrect results.
|
||||
Since the C++ Kiwi library is well tested and widely used it was simpler to provide a LuaJIT FFI wrapper and use that.
|
||||
This package has no dependencies other than a C++11 toolchain to compile the included Kiwi library and a small C wrapper.
|
||||
This package has no dependencies other than a C++14 toolchain to compile the included Kiwi library and a small C wrapper.
|
||||
|
||||
The Lua API has a pure Lua expression builder. There is of course some overhead to this, however in most cases expression building is infrequent and the underlying structures can be reused.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user