The latter returns a null pointer (and sets the string size to zero) if
the conversion fails, which the following code neglects to check,
potentially leading to null pointer dereferences.
Instead use the former, which throws a helpful type error if it fails
and doesn't expose the code to null pointers.
The Lua stack is guaranteed to have at least LUA_MINSTACK (default 20)
slots upon entry to C. Check to see if we might need more than that
minimum and only in that case call the function to check and resize the
stack. In virtually all cases the check can then be optimized away.
Additionally remove the redundant "Out of stack" message. Lua already
says "stack overflow" and a null message is valid.
Saves ~330B.