In the section describing luaL_Buffer[1], the description of use when the size is known in advance says you finish with luaL_pushresult(), giving it a pointer to your buffer, and the final size. This function takes only one argument: I suspect it is meant to say you should use luaL_pushresultsize(). B. [1] <http://www.lua.org/manual/5.2/manual.html#luaL_Buffer>