lua-users home
lua-l archive

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


On Sat, Nov 2, 2019 at 2:10 PM Abhijit Nandy <abhijit.nandy@gmail.com> wrote:

> If I comment out:  memcpy(backupBuffer, buffer, 4096)    then things are fine.

No they are not. Your buffers are too small and you have a buffer overrun in any case. However, with the memcpy in place, it modifies the the content of the overrun memory so you see the problem earlier.

Another problem is that you call luaL_newstate() and then lua_setallocf(). The first call will already have allocated some memory using the default allocator. This is benign for now, but may bite you in future. Use lua_newstate() instead.

Cheers,
V.