commit fc4a32fe98f1da8b07f74a35f40b678692e7152b from: Sergey Bronnikov date: Fri Aug 29 10:40:58 2025 UTC luzer: fix compilation with latest PUC Rio Lua The compilation is broken with the latest version of PUC Rio Lua: ``` /home/runner/work/lua-c-api-tests/lua-c-api-tests/build/luzer/source/luzer/custom_mutator_lib.c:19:33: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int] 19 | size_t lua_objlen(lua_State *L, int index); | ^ /home/runner/work/lua-c-api-tests/lua-c-api-tests/build/luzer/source/luzer/custom_mutator_lib.c:19:8: error: conflicting types for 'lua_rawlen' 19 | size_t lua_objlen(lua_State *L, int index); | ^ /home/runner/work/lua-c-api-tests/lua-c-api-tests/build/lua-master/source/luaconf.h:357:26: note: expanded from macro 'lua_objlen' 357 | #define lua_objlen(L,i) lua_rawlen(L, (i)) | ^ /home/runner/work/lua-c-api-tests/lua-c-api-tests/build/lua-master/source/lua.h:204:26: note: previous declaration is here 204 | LUA_API lua_Unsigned (lua_rawlen) (lua_State *L, int idx); | ^ 2 errors generated. ``` The patch fixes that by adding a macro `lua_objlen`, the function `lua_objlen()` is not available in Lua 5.2+ as it was renamed to `lua_rawlen()`, see "8.3 – Changes in the API" in Lua 5.2 Reference Manual [1]. Also, linkage specification under the macro `__cplusplus` was removed because it is not needed. 1. https://www.lua.org/manual/5.2/manual.html commit - 6e4d95a834a9c74f8a77acb4b2bf482add70f185 commit + fc4a32fe98f1da8b07f74a35f40b678692e7152b blob - 2590b9da034eae88ebfe77e819f72723b4d10650 blob + f0ed6ae23152131076f10ae72ad98a069b35f6fc --- luzer/custom_mutator_lib.c +++ luzer/custom_mutator_lib.c @@ -12,14 +12,9 @@ #include "luzer.h" -#ifdef __cplusplus -extern "C" { +#if LUA_VERSION_NUM == 501 +#define lua_rawlen(L, i) lua_objlen((L), (i)) #endif -int luaL_error(lua_State *L, const char *fmt, ...); -size_t lua_objlen(lua_State *L, int index); -#ifdef __cplusplus -} /* extern "C" */ -#endif size_t LLVMFuzzerCustomMutator(uint8_t* data, size_t size, @@ -31,7 +26,7 @@ LLVMFuzzerCustomMutator(uint8_t* data, size_t size, lua_pushinteger(L, seed); luaL_mutate(L); - size_t sz = lua_objlen(L, -1); + size_t sz = lua_rawlen(L, -1); if (sz > max_size) luaL_error(L, "The size of mutated data cannot be larger than a max_size."); const char *buf = lua_tostring(L, -1);