lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Apr 16, 2018 at 6:04 PM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

> Practically all functions in the Lua-C API can crash, when called with invalid arguments.

In the referenced thread, the C-language arguments given to the function were not invalid. It was the content of the Lua stack that was problematic for that function.

In the "checking for safety" context, that means the stack's content should be validated, if it is accepted from another party.

> I believe this happens with most C libraries.

No, not really. It is one thing if a parameter in a C function is a pointer, then the argument simply has to point to a valid memory location. It is quite another when it is a kind of a "handle", then it is rather typical for a function to return an error result if the argument has an invalid or unsuitable value. See POSIX/read(), for example. Lua's stack indices look more like handles than pointers to me, but that, of course, can be just me.

Cheers,
V.