lua-users home
lua-l archive

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



when prepbuffsize is called, because my stack contains the function being dumped at the top (since that's what lua_dump needs), and prepbufsize does:

So you are violating:
You can use the stack between successive calls to buffer operations as long as that use is balanced from https://www.lua.org/manual/5.4/manual.html#luaL_Buffer since you push the function after a buffer operation without removing it before the next buffer operation in the write function.

You could argue that the design of either buffer or dump should be changed. Buffers could include the stack slot they occupy since now they allway occuply exactly one or dump could get a index to the function instead of requireing in on the top.

It is also interesting so see how lua solved this issue for string.dump here https://github.com/lua/lua/blob/fc6c74f1004b5f67d0503633ddb74174a3c8d6ad/lstrlib.c#L222-L230.

Regards,
Xmilia