[{"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 35, "message": "Variable 'lua_ident' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 35, "message": "File-scope variable should have minimal scope. Consider making it static within a function or limiting its scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Move variable to the smallest scope where it's used, or make it static inside a function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 109, "message": "Function 'lua_checkstack' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 109, "message": "Function 'lua_checkstack' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 109, "message": "Function 'lua_checkstack' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_checkstack"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 126, "message": "Function 'lua_xmove' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_xmove"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 142, "message": "Function 'lua_CFunction' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 152, "message": "Function 'lua_version' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_version"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 167, "message": "Function 'lua_absindex' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 167, "message": "Function 'lua_absindex' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_absindex"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 167, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 174, "message": "Function 'lua_gettop' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 174, "message": "Function 'lua_gettop' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_gettop"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 174, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 179, "message": "Function 'lua_settop' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 179, "message": "Function 'lua_settop' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_settop"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 206, "message": "Function 'lua_closeslot' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 206, "message": "Function 'lua_closeslot' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_closeslot"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 207, "message": "Variable 'level' should be declared volatile - modified around function calls that may have external side effects", "rule_id": "DCL22-C", "severity": "Low", "suggestion": "Declare as 'volatile' to prevent compiler optimizations that assume variable state is unchanged across function calls"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 238, "message": "Function 'lua_rotate' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 238, "message": "Function 'lua_rotate' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 238, "message": "Function 'lua_rotate' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_rotate"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 253, "message": "Function 'lua_copy' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 253, "message": "Function 'lua_copy' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_copy"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 268, "message": "Function 'lua_pushvalue' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 268, "message": "Function 'lua_pushvalue' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_pushvalue"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 282, "message": "Function 'lua_type' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 282, "message": "Function 'lua_type' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_type"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 288, "message": "Function 'lua_typename' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 295, "message": "Function 'lua_iscfunction' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 295, "message": "Function 'lua_iscfunction' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_iscfunction"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 301, "message": "Function 'lua_isinteger' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 301, "message": "Function 'lua_isinteger' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_isinteger"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 307, "message": "Function 'lua_isnumber' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 307, "message": "Function 'lua_isnumber' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_isnumber"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 314, "message": "Function 'lua_isstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 314, "message": "Function 'lua_isstring' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_isstring"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 320, "message": "Function 'lua_isuserdata' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 320, "message": "Function 'lua_isuserdata' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_isuserdata"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 326, "message": "Function 'lua_rawequal' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 326, "message": "Function 'lua_rawequal' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_rawequal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 333, "message": "Function 'lua_arith' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 333, "message": "Function 'lua_arith' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_arith"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 343, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 349, "message": "Function 'lua_compare' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 349, "message": "Function 'lua_compare' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_compare"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 369, "message": "Function 'lua_numbertocstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 369, "message": "Function 'lua_numbertocstring' does not validate pointer parameter 'buff' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'buff' at the start of the function, e.g., 'if (!buff) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 381, "message": "Function 'lua_stringtonumber' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 381, "message": "Function 'lua_stringtonumber' does not validate pointer parameter 's' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 381, "message": "Function 'lua_stringtonumber' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_stringtonumber"}, {"column": 28, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 382, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 389, "message": "Function 'lua_tonumberx' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 389, "message": "Function 'lua_tonumberx' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_tonumberx"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 399, "message": "Function 'lua_tointegerx' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 399, "message": "Function 'lua_tointegerx' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_tointegerx"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 409, "message": "Function 'lua_toboolean' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 409, "message": "Function 'lua_toboolean' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_toboolean"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 437, "message": "Function 'lua_Unsigned' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 455, "message": "Function 'lua_tocfunction' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 455, "message": "Function 'lua_tocfunction' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_tocfunction"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 464, "message": "Function 'touserdata' does not validate pointer parameter 'o' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'o' at the start of the function, e.g., 'if (!o) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 464, "message": "Function 'touserdata' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline touserdata"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 473, "message": "Function 'lua_touserdata' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 479, "message": "Function 'lua_tothread' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 492, "message": "Function 'lua_topointer' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 514, "message": "Function 'lua_pushnil' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 514, "message": "Function 'lua_pushnil' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_pushnil"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 522, "message": "Function 'lua_pushnumber' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 522, "message": "Function 'lua_pushnumber' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_pushnumber"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 530, "message": "Function 'lua_pushinteger' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 530, "message": "Function 'lua_pushinteger' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_pushinteger"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 543, "message": "Function 'lua_pushlstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 543, "message": "Function 'lua_pushlstring' does not validate pointer parameter 's' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"}, {"column": 63, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 543, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 555, "message": "Function 'lua_pushexternalstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 555, "message": "Function 'lua_pushexternalstring' does not validate pointer parameter 's' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 555, "message": "Function 'lua_pushexternalstring' does not validate pointer parameter 'ud' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ud' at the start of the function, e.g., 'if (!ud) { return error_code; }'"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 556, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 60, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 556, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 570, "message": "Function 'lua_pushstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 6, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 572, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 576, "message": "Memory allocated with 'luaS_new' for variable 'ts' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(ts)' before the variable goes out of scope"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 583, "message": "Memory leak: 'ts' allocated with 'luaS_new' is not freed before return", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Free 'ts' before this return statement"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 587, "message": "Function 'lua_pushvfstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 587, "message": "Function 'lua_pushvfstring' does not validate pointer parameter 'fmt' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fmt' at the start of the function, e.g., 'if (!fmt) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 594, "message": "Function returns pointer to local variable 'ret' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 598, "message": "Function 'lua_pushfstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 598, "message": "Function 'lua_pushfstring' does not validate pointer parameter 'fmt' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fmt' at the start of the function, e.g., 'if (!fmt) { return error_code; }'"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 602, "message": "Variable 'argp' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'argp' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 605, "message": "Function returns pointer to local variable 'ret' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 609, "message": "Function 'lua_pushcclosure' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 609, "message": "Function 'lua_pushcclosure' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_pushcclosure"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 621, "message": "Potential null pointer dereference in member access of variable 'cl'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'cl' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 636, "message": "Function 'lua_pushboolean' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 636, "message": "Function 'lua_pushboolean' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_pushboolean"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 647, "message": "Function 'lua_pushlightuserdata' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 647, "message": "Function 'lua_pushlightuserdata' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 647, "message": "Function 'lua_pushlightuserdata' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_pushlightuserdata"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 655, "message": "Function 'lua_pushthread' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 655, "message": "Function 'lua_pushthread' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_pushthread"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 657, "message": "Function 'setthvalue' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 672, "message": "Memory allocated with 'luaS_new' for variable 'str' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(str)' before the variable goes out of scope"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 682, "message": "Memory leak: 'str' allocated with 'luaS_new' is not freed before return", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Free 'str' before this return statement"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 699, "message": "Function 'lua_getglobal' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 699, "message": "Function 'lua_getglobal' does not validate pointer parameter 'name' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'name' at the start of the function, e.g., 'if (!name) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 699, "message": "Function 'lua_getglobal' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_getglobal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 707, "message": "Function 'lua_gettable' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 707, "message": "Function 'lua_gettable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_gettable"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 713, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 721, "message": "Function 'lua_getfield' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 721, "message": "Function 'lua_getfield' does not validate pointer parameter 'k' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'k' at the start of the function, e.g., 'if (!k) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 721, "message": "Function 'lua_getfield' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_getfield"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 727, "message": "Function 'lua_geti' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 727, "message": "Function 'lua_geti' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_geti"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 753, "message": "Function 'gettable' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 753, "message": "Function 'gettable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline gettable"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 760, "message": "Function 'lua_rawget' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 760, "message": "Function 'lua_rawget' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_rawget"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 766, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 772, "message": "Function 'lua_rawgeti' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 772, "message": "Function 'lua_rawgeti' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_rawgeti"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 782, "message": "Function 'lua_rawgetp' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 782, "message": "Function 'lua_rawgetp' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 782, "message": "Function 'lua_rawgetp' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_rawgetp"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 792, "message": "Function 'lua_createtable' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 792, "message": "Function 'lua_createtable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_createtable"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 795, "message": "Memory allocated with 'luaH_new' for variable 't' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(t)' before the variable goes out of scope"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 799, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 805, "message": "Function 'lua_getmetatable' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 805, "message": "Function 'lua_getmetatable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_getmetatable"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 832, "message": "Function 'lua_getiuservalue' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 832, "message": "Function 'lua_getiuservalue' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_getiuservalue"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 861, "message": "Memory allocated with 'luaS_new' for variable 'str' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(str)' before the variable goes out of scope"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 871, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 878, "message": "Function 'lua_setglobal' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 878, "message": "Function 'lua_setglobal' does not validate pointer parameter 'name' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'name' at the start of the function, e.g., 'if (!name) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 878, "message": "Function 'lua_setglobal' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_setglobal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 886, "message": "Function 'lua_settable' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 886, "message": "Function 'lua_settable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_settable"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 892, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 896, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 902, "message": "Function 'lua_setfield' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 902, "message": "Function 'lua_setfield' does not validate pointer parameter 'k' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'k' at the start of the function, e.g., 'if (!k) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 902, "message": "Function 'lua_setfield' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_setfield"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 908, "message": "Function 'lua_seti' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 908, "message": "Function 'lua_seti' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_seti"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 934, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 940, "message": "Function 'lua_rawset' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 940, "message": "Function 'lua_rawset' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_rawset"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 945, "message": "Function 'lua_rawsetp' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 945, "message": "Function 'lua_rawsetp' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 945, "message": "Function 'lua_rawsetp' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_rawsetp"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 952, "message": "Function 'lua_rawseti' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 952, "message": "Function 'lua_rawseti' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_rawseti"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 958, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 964, "message": "Function 'lua_setmetatable' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 964, "message": "Function 'lua_setmetatable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_setmetatable"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1004, "message": "Function 'lua_setiuservalue' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1004, "message": "Function 'lua_setiuservalue' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1004, "message": "Function 'lua_setiuservalue' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_setiuservalue"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1015, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1029, "message": "Function-like macro 'checkresults' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1029, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1029, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1037, "message": "Function 'lua_callk' does not validate integer parameter 'nargs' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'nargs' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1037, "message": "Function 'lua_callk' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_callk"}, {"column": 40, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1069, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1070, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1076, "message": "Function 'lua_pcallk' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1076, "message": "Function 'lua_pcallk' does not validate integer parameter 'nargs' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'nargs' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1076, "message": "Function 'lua_pcallk' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_pcallk"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1120, "message": "Function 'lua_load' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1120, "message": "Function 'lua_load' does not validate pointer parameter 'data' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'data' at the start of the function, e.g., 'if (!data) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1120, "message": "Function 'lua_load' does not validate pointer parameter 'chunkname' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'chunkname' at the start of the function, e.g., 'if (!chunkname) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1120, "message": "Function 'lua_load' does not validate pointer parameter 'mode' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'mode' at the start of the function, e.g., 'if (!mode) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1120, "message": "Function 'lua_load' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_load"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1149, "message": "Function 'lua_dump' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1149, "message": "Function 'lua_dump' does not validate pointer parameter 'data' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'data' at the start of the function, e.g., 'if (!data) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1149, "message": "Function 'lua_dump' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_dump"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1163, "message": "Function 'lua_status' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1163, "message": "Function 'lua_status' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_status"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1163, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1171, "message": "Function 'lua_gc' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_gc"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1174, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1175, "message": "Variable 'g' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1195, "message": "Do not assume constant values in expressions: 'gettotalbytes(g) >> 10'", "rule_id": "EXP07-C", "severity": "Low", "suggestion": "Use the constant identifier directly instead of assuming its numeric value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1258, "message": "Function 'lua_error' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1258, "message": "Function 'lua_error' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_error"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1273, "message": "Function 'lua_next' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1273, "message": "Function 'lua_next' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_next"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1289, "message": "Function 'lua_toclose' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1289, "message": "Function 'lua_toclose' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_toclose"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1300, "message": "Function 'lua_concat' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1300, "message": "Function 'lua_concat' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_concat"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1315, "message": "Function 'lua_len' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1315, "message": "Function 'lua_len' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_len"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1325, "message": "Function 'lua_getallocf' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1325, "message": "Function 'lua_getallocf' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_getallocf"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1335, "message": "Function 'lua_setallocf' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1335, "message": "Function 'lua_setallocf' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_setallocf"}, {"column": 61, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1335, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1343, "message": "Function 'lua_setwarnf' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1343, "message": "Function 'lua_setwarnf' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static void lua_setwarnf"}, {"column": 59, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1343, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1351, "message": "Function 'lua_warning' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1351, "message": "Function 'lua_warning' does not validate pointer parameter 'msg' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'msg' at the start of the function, e.g., 'if (!msg) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1351, "message": "Function 'lua_warning' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static void lua_warning"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1359, "message": "Function 'lua_newuserdatauv' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1380, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1400, "message": "Function 'lua_getupvalue' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1400, "message": "Function 'lua_getupvalue' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1410, "message": "Function returns pointer to local variable 'name' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1414, "message": "Function 'lua_setupvalue' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1414, "message": "Function 'lua_setupvalue' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1429, "message": "Function returns pointer to local variable 'name' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1439, "message": "Local variable 'f' assigned through pointer parameter - address will be invalid when function returns", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Copy data instead of assigning pointer, or use static/allocated storage"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1447, "message": "Function 'lua_upvalueid' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1447, "message": "Function 'lua_upvalueid' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1469, "message": "Function 'lua_upvaluejoin' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1469, "message": "Function 'lua_upvaluejoin' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_upvaluejoin"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1472, "message": "Pointer-to-pointer assignment may allow const circumvention: **up1 = getupvalref(L, fidx1, n1, &f1): '**up1 = getupvalref(L, fidx1, n1, &f1)'", "rule_id": "EXP40-C", "severity": "Low", "suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1474, "message": "Potential null pointer dereference of variable 'up1'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'up1' is not NULL before dereferencing"}, {"column": 32, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1474, "message": "Potential null pointer dereference of variable 'up2'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'up2' is not NULL before dereferencing"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1475, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lapi.c", "line": 1476, "message": "Variable 'f1' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'f1' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 25, "message": "Function-like macro 'api_incr_top' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 25, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 25, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 45, "message": "Function-like macro 'adjustresults' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 45, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 45, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ if ((nres) <= LUA_MULTRET && L->ci->top.p < L->top.p) \\\n\tL->ci->top.p = L->top.p; })"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 45, "message": "Multistatement macro 'adjustresults' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 45, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 51, "message": "Function-like macro 'api_checknelems' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 51, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 51, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (api_check(L, (n) < (L->top.p - L->ci->func.p), \\\n \"not enough elements in the stack\"))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 51, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 60, "message": "Function-like macro 'api_checkpop' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 60, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 60, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (api_check(L, (n) < L->top.p - L->ci->func.p && \\\n L->tbclist.p < L->top.p - (n), \\\n\t\t\t \"not enough free elements in the stack\"))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lapi.h", "line": 60, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 47, "message": "Recursive function can cause excessive stack allocation", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Consider iterative approach or limit recursion depth"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 127, "message": "Function 'luaL_traceback' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 127, "message": "Function 'luaL_traceback' does not validate pointer parameter 'L1' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L1' at the start of the function, e.g., 'if (!L1) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 127, "message": "Function 'luaL_traceback' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_traceback"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 171, "message": "Function 'luaL_argerror' does not validate pointer parameter 'extramsg' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'extramsg' at the start of the function, e.g., 'if (!extramsg) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 171, "message": "Function 'luaL_argerror' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_argerror"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 171, "message": "Function 'luaL_argerror' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_argerror'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 197, "message": "Function 'luaL_typeerror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 197, "message": "Function 'luaL_typeerror' does not validate pointer parameter 'tname' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'tname' at the start of the function, e.g., 'if (!tname) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 197, "message": "Function 'luaL_typeerror' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_typeerror"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 197, "message": "Function 'luaL_typeerror' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_typeerror'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 220, "message": "Function 'luaL_where' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 220, "message": "Function 'luaL_where' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_where"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 220, "message": "Function 'luaL_where' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_where'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 238, "message": "Function 'luaL_error' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 238, "message": "Function 'luaL_error' does not validate pointer parameter 'fmt' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fmt' at the start of the function, e.g., 'if (!fmt) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 238, "message": "Function 'luaL_error' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_error"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 238, "message": "Function 'luaL_error' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_error'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 249, "message": "Function 'luaL_fileresult' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_fileresult"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 249, "message": "Function 'luaL_fileresult' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_fileresult'"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 258, "message": "Call to non-thread-safe function 'strerror'. Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting", "rule_id": "CON33-C", "severity": "Medium", "suggestion": "Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 258, "message": "'strerror()' uses internal static storage that is shared between threads", "rule_id": "CON34-C", "severity": "Medium", "suggestion": "Use 'strerror_r' instead for thread safety"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 278, "message": "Function-like macro 'l_inspectstat' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 278, "message": "Macro parameter 'stat' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'stat' in parentheses: (stat) instead of stat"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 278, "message": "Macro parameter 'what' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'what' in parentheses: (what) instead of what"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 278, "message": "Multistatement macro 'l_inspectstat' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 278, "message": "Macro evaluates parameter 'stat' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 291, "message": "Function 'luaL_execresult' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_execresult"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 317, "message": "Function 'luaL_newmetatable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_newmetatable"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 317, "message": "Function 'luaL_newmetatable' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_newmetatable'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 323, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 330, "message": "Function 'luaL_setmetatable' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 330, "message": "Function 'luaL_setmetatable' does not validate pointer parameter 'tname' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'tname' at the start of the function, e.g., 'if (!tname) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 330, "message": "Function 'luaL_setmetatable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_setmetatable"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 336, "message": "Function 'luaL_testudata' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 344, "message": "Function returns pointer to local variable 'p' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 351, "message": "Function 'luaL_checkudata' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 351, "message": "Function 'luaL_checkudata' does not validate pointer parameter 'tname' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'tname' at the start of the function, e.g., 'if (!tname) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 354, "message": "Function returns pointer to local variable 'p' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 366, "message": "Function 'luaL_checkoption' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 366, "message": "Function 'luaL_checkoption' does not validate pointer parameter 'def' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'def' at the start of the function, e.g., 'if (!def) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 366, "message": "Function 'luaL_checkoption' does not validate pointer parameter 'lst' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'lst' at the start of the function, e.g., 'if (!lst) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 366, "message": "Function 'luaL_checkoption' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkoption"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 386, "message": "Function 'luaL_checkstack' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkstack"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 386, "message": "Function 'luaL_checkstack' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_checkstack'"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 387, "message": "Implicit boolean test on 'lua_checkstack(L, space)'. May be unclear what constitutes success or failure.", "rule_id": "EXP20-C", "severity": "Medium", "suggestion": "Use explicit test: lua_checkstack(L, space) == 0 or lua_checkstack(L, space) != 0 depending on success convention"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 396, "message": "Function 'luaL_checktype' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checktype"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 402, "message": "Function 'luaL_checkany' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkany"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 408, "message": "Function 'luaL_checklstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 411, "message": "Function returns pointer to local variable 's' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 415, "message": "Function 'luaL_optlstring' does not validate pointer parameter 'len' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'len' at the start of the function, e.g., 'if (!len) { return error_code; }'"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 416, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 426, "message": "Function 'luaL_checknumber' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 426, "message": "Function 'luaL_checknumber' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checknumber"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 429, "message": "Variable 'isnum' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'isnum' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 435, "message": "Function 'luaL_optnumber' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 435, "message": "Function 'luaL_optnumber' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_optnumber"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 448, "message": "Function 'luaL_checkinteger' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 448, "message": "Function 'luaL_checkinteger' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkinteger"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 451, "message": "Variable 'isnum' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'isnum' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 458, "message": "Function 'luaL_optinteger' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 458, "message": "Function 'luaL_optinteger' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_optinteger"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 486, "message": "Potential null pointer dereference in member access of variable 'box'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'box' is not NULL before member access"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 491, "message": "Function 'allocf' is called without prior declaration", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Declare the function before calling it or include the appropriate header"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 491, "message": "Variable 'ud' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ud' before use, e.g., at its declaration"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 509, "message": "Array declaration 'boxmt[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 518, "message": "Potential null pointer dereference in member access of variable 'box'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'box' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 530, "message": "Function-like macro 'buffonstack' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 530, "message": "Macro evaluates parameter 'B' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 537, "message": "Function-like macro 'checkbufferlevel' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 537, "message": "Macro parameter 'B' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'B' in parentheses: (B) instead of B"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 537, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (lua_assert(buffonstack(B) ? lua_touserdata(B->L, idx) != NULL \\\n : lua_touserdata(B->L, idx) == (void*)B))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 537, "message": "Macro evaluates parameter 'B' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 40, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 546, "message": "Pointer parameter 'B' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *B'"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 552, "message": "Variable 'newsize' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 581, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 581, "message": "memcpy() size argument contains arithmetic that may overflow: 'B->n * sizeof(char)'", "rule_id": "INT32-C", "severity": "High", "suggestion": "Validate size calculations before passing to memory functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 592, "message": "Function 'luaL_prepbuffsize' does not validate pointer parameter 'B' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 597, "message": "Function 'luaL_addlstring' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_addlstring"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 597, "message": "Function 'luaL_addlstring' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_addlstring'"}, {"column": 61, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 597, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 600, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 600, "message": "Do not cast away const qualification: 'b'", "rule_id": "EXP05-C", "severity": "Medium", "suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 600, "message": "Passing potentially null pointer 'b' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'b' is not NULL before passing to function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 606, "message": "Function 'luaL_addstring' does not validate pointer parameter 'B' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 606, "message": "Function 'luaL_addstring' does not validate pointer parameter 's' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 606, "message": "Function 'luaL_addstring' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_addstring"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 606, "message": "Function 'luaL_addstring' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_addstring'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 611, "message": "Function 'luaL_pushresult' does not validate pointer parameter 'B' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 611, "message": "Function 'luaL_pushresult' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_pushresult"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 611, "message": "Function 'luaL_pushresult' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_pushresult'"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 623, "message": "Potential null pointer dereference in member access of variable 'box'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'box' is not NULL before member access"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 627, "message": "Variable 'ud' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ud' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 635, "message": "Function 'luaL_pushresultsize' does not validate pointer parameter 'B' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 635, "message": "Function 'luaL_pushresultsize' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_pushresultsize"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 650, "message": "Function 'luaL_addvalue' does not validate pointer parameter 'B' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 650, "message": "Function 'luaL_addvalue' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_addvalue"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 650, "message": "Function 'luaL_addvalue' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_addvalue'"}, {"column": 29, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 654, "message": "Variable 'len' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 655, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 655, "message": "Do not cast away const qualification: 'b'", "rule_id": "EXP05-C", "severity": "Medium", "suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 655, "message": "Passing potentially null pointer 'b' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'b' is not NULL before passing to function"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 655, "message": "Passing potentially null pointer 's' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before passing to function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 661, "message": "Function 'luaL_buffinit' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 661, "message": "Function 'luaL_buffinit' does not validate pointer parameter 'B' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 661, "message": "Function 'luaL_buffinit' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_buffinit"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 661, "message": "Function 'luaL_buffinit' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_buffinit'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 670, "message": "Function 'luaL_buffinitsize' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 670, "message": "Function 'luaL_buffinitsize' does not validate pointer parameter 'B' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'B' at the start of the function, e.g., 'if (!B) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 689, "message": "Function 'luaL_ref' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_ref"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 710, "message": "Function 'lua_rawlen' is called without prior declaration", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Declare the function before calling it or include the appropriate header"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 716, "message": "Function 'luaL_unref' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_unref"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 743, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 755, "message": "Function 'fread' count parameter appears to use total size instead of element count", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Use element count, not total byte size. Example: fread(buf, sizeof(elem), count, file)"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 755, "message": "fread() used without explicitly accounting for null terminator in character buffer", "rule_id": "FIO17-C", "severity": "Medium", "suggestion": "Ensure buffer size accounts for null terminator, or explicitly add null terminator after fread()"}, {"column": 60, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 765, "message": "Call to non-thread-safe function 'strerror'. Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting", "rule_id": "CON33-C", "severity": "Medium", "suggestion": "Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting"}, {"column": 60, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 765, "message": "'strerror()' uses internal static storage that is shared between threads", "rule_id": "CON34-C", "severity": "Medium", "suggestion": "Use 'strerror_r' instead for thread safety"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 779, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 780, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 796, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 5, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 798, "message": "EOF comparison without feof()/ferror() verification: 'do { /* skip first line */'", "rule_id": "FIO34-C", "severity": "High", "suggestion": "After EOF is detected, call feof() and ferror() to distinguish between end-of-file and I/O error"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 808, "message": "Function 'luaL_loadfilex' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 808, "message": "Function 'luaL_loadfilex' does not validate pointer parameter 'mode' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'mode' at the start of the function, e.g., 'if (!mode) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 808, "message": "Function 'luaL_loadfilex' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_loadfilex"}, {"column": 6, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 814, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 821, "message": "File opened for reading using variable filename 'filename' without verifying file attributes (fstat + st_uid/st_gid check)", "rule_id": "FIO05-C", "severity": "Medium", "suggestion": "Use fstat() to check file ownership (st_uid, st_gid) before reading untrusted files"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 821, "message": "fopen() called without 'N' flag in mode string \"r\". On Windows, file handles are inheritable by default unless the 'N' flag is specified.", "rule_id": "WIN03-C", "severity": "High", "suggestion": "Add 'N' flag to the mode string (e.g., \"rwN\") to disable handle inheritance on Windows."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 827, "message": "Variable 'c' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'c' before use, e.g., at its declaration"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 831, "message": "Return value of 'freopen' assigned to 'lf.f' but not checked for errors: 'freopen(filename, \"rb\", lf.f)' - Can return error indicator", "rule_id": "ERR33-C", "severity": "High", "suggestion": "Check return value for errors"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 832, "message": "Function returns without releasing all resources. Leaked: lf.f, lf.f. Consider using goto chain for proper resource cleanup.", "rule_id": "MEM12-C", "severity": "Low", "suggestion": "Use goto chain pattern with cleanup labels to ensure all resources are released"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 841, "message": "Return value from fclose() is ignored. Error handling is required.", "rule_id": "ERR00-C", "severity": "Medium", "suggestion": "Store and check the return value from fclose()"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 841, "message": "Return value of 'fclose' ignored: 'fclose(lf.f)' - Returns non-zero on error", "rule_id": "ERR33-C", "severity": "High", "suggestion": "Check if (fclose(file) != 0) for close errors"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 857, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 867, "message": "Function 'luaL_loadbufferx' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 867, "message": "Function 'luaL_loadbufferx' does not validate pointer parameter 'buff' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'buff' at the start of the function, e.g., 'if (!buff) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 867, "message": "Function 'luaL_loadbufferx' does not validate pointer parameter 'mode' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'mode' at the start of the function, e.g., 'if (!mode) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 867, "message": "Function 'luaL_loadbufferx' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_loadbufferx"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 867, "message": "Function 'luaL_loadbufferx' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_loadbufferx'"}, {"column": 59, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 867, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 868, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 63, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 868, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 876, "message": "Function 'luaL_loadstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 876, "message": "Function 'luaL_loadstring' does not validate pointer parameter 's' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 876, "message": "Function 'luaL_loadstring' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_loadstring"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 884, "message": "Function 'luaL_getmetafield' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_getmetafield"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 884, "message": "Function 'luaL_getmetafield' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_getmetafield'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 900, "message": "Function 'luaL_callmeta' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_callmeta"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 900, "message": "Function 'luaL_callmeta' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_callmeta'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 910, "message": "Function 'lua_Integer' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 922, "message": "Function 'luaL_tolstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 965, "message": "Function 'luaL_setfuncs' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 965, "message": "Function 'luaL_setfuncs' does not validate pointer parameter 'l' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'l' at the start of the function, e.g., 'if (!l) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 965, "message": "Function 'luaL_setfuncs' does not validate integer parameter 'nup' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'nup' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 965, "message": "Function 'luaL_setfuncs' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_setfuncs"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 965, "message": "Function 'luaL_setfuncs' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_setfuncs'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 986, "message": "Function 'luaL_getsubtable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_getsubtable"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 986, "message": "Function 'luaL_getsubtable' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_getsubtable'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1006, "message": "Function 'luaL_requiref' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1006, "message": "Function 'luaL_requiref' does not validate pointer parameter 'modname' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'modname' at the start of the function, e.g., 'if (!modname) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1006, "message": "Function 'luaL_requiref' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_requiref"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1026, "message": "Function 'luaL_addgsub' does not validate pointer parameter 'b' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'b' at the start of the function, e.g., 'if (!b) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1026, "message": "Function 'luaL_addgsub' does not validate pointer parameter 's' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1026, "message": "Function 'luaL_addgsub' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1026, "message": "Function 'luaL_addgsub' does not validate pointer parameter 'r' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'r' at the start of the function, e.g., 'if (!r) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1026, "message": "Function 'luaL_addgsub' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_addgsub"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1026, "message": "Function 'luaL_addgsub' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaL_addgsub'"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1029, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1039, "message": "Function 'luaL_gsub' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1039, "message": "Function 'luaL_gsub' does not validate pointer parameter 's' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1039, "message": "Function 'luaL_gsub' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1039, "message": "Function 'luaL_gsub' does not validate pointer parameter 'r' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'r' at the start of the function, e.g., 'if (!r) { return error_code; }'"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1049, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1049, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1052, "message": "Pointer 'ptr' freed without clearing sensitive data first", "rule_id": "MEM03-C", "severity": "Medium", "suggestion": "Add 'memset(ptr, 0, size);' before free(ptr) to clear sensitive data"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1056, "message": "Mixed string management approaches detected. Static char array at line 931 and dynamic allocation at line 1056. Consider adopting a consistent approach.", "rule_id": "STR01-C", "severity": "Low", "suggestion": "Adopt either static string arrays OR dynamic allocation consistently throughout the codebase. Document the chosen approach in coding standards."}, {"column": 12, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1056, "message": "Sensitive data allocated with realloc may be written to disk. Use mlock() (POSIX) or VirtualLock() (Windows) to lock memory pages, or use setrlimit(RLIMIT_CORE, 0) to disable core dumps.", "rule_id": "MEM06-C", "severity": "Medium", "suggestion": "Consider using mlock()/munlock() to prevent memory from being swapped to disk, or use setrlimit() to disable core dumps."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1094, "message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1096, "message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1115, "message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1118, "message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1152, "message": "Function-like macro 'addbuff' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1152, "message": "Macro parameter 'b' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'b' in parentheses: (b) instead of b"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1152, "message": "Macro evaluates parameter 'b' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1159, "message": "Return value of 'time' assigned to 't' but not checked for errors: 'time(NULL)' - Returns (time_t)(-1) on failure", "rule_id": "ERR33-C", "severity": "High", "suggestion": "Check if (result == (time_t)(-1)) for time errors"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1160, "message": "Variable 'buff' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'buff' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1161, "message": "Function 'addbuff' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1164, "message": "memset() size argument contains arithmetic that may overflow: 'sizeof(buff) - BUFSEEDB'", "rule_id": "INT32-C", "severity": "High", "suggestion": "Validate size calculations before passing to memory functions"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1164, "message": "Do not cast away const qualification: 'b'", "rule_id": "EXP05-C", "severity": "Medium", "suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1167, "message": "Variable 'res' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1167, "message": "Output operation on file stream 'res' follows input without intervening positioning call (fseek, fsetpos, or rewind)", "rule_id": "FIO50-C", "severity": "Low", "suggestion": "Insert a positioning function (fseek, fsetpos, rewind) between input and output operations, unless input encountered EOF"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1167, "message": "Output operation on file stream 'res' follows input without intervening positioning call (fseek, fsetpos, or rewind)", "rule_id": "FIO50-C", "severity": "Low", "suggestion": "Insert a positioning function (fseek, fsetpos, rewind) between input and output operations, unless input encountered EOF"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1167, "message": "Reading from uninitialized array 'buff' inside a loop. Array was declared but never initialized before being read.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Initialize array 'buff' before reading: int buff[N] = {0}; or assign values before use"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1187, "message": "Function 'lua_atpanic' is called without prior declaration", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Declare the function before calling it or include the appropriate header"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1188, "message": "Function 'lua_setwarnf' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1190, "message": "Function returns pointer to local variable 'L' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1194, "message": "Function 'luaL_checkversion_' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.c", "line": 1194, "message": "Function 'luaL_checkversion_' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_checkversion_"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 52, "message": "Function has pointer parameter without size argument: 'LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'size_t *len' to specify the maximum number of elements in the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 55, "message": "Function has pointer parameter without size argument: 'LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'size_t *l' to specify the maximum number of elements in the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 57, "message": "Function has pointer parameter without size argument: 'LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'size_t *l' to specify the maximum number of elements in the array"}, {"column": 54, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 58, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 60, "message": "Incompatible declarations of function 'lua_Number': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 63, "message": "Incompatible declarations of function 'lua_Integer': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 66, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 67, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 68, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 70, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 71, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 75, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 76, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 76, "message": "Variadic function declaration should use proper header", "rule_id": "EXP37-C", "severity": "Medium", "suggestion": "Include proper header instead of declaring variadic function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 78, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 54, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 79, "message": "Array declaration 'lst[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 82, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 84, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 84, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 92, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 93, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 95, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 100, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 61, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 100, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 101, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 65, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 101, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 102, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 110, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 115, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 119, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 122, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 132, "message": "Function-like macro 'luaL_newlibtable' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 132, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 132, "message": "Macro evaluates parameter 'l' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 135, "message": "Macro 'luaL_newlib' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 135, "message": "Function-like macro 'luaL_newlib' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 135, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 147, "message": "Function-like macro 'luaL_typename' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 147, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 149, "message": "Function-like macro 'luaL_dofile' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 149, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 152, "message": "Function-like macro 'luaL_dostring' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 152, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 157, "message": "Function-like macro 'luaL_opt' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 157, "message": "Macro parameter 'f' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'f' in parentheses: (f) instead of f"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 157, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 166, "message": "Macro parameter 'op' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'op' in parentheses: (op) instead of op"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 201, "message": "Function-like macro 'luaL_addchar' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 201, "message": "Macro evaluates parameter 'B' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 209, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 211, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 63, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 211, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 212, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 213, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 214, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 215, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lauxlib.h", "line": 258, "message": "Macro 'luaL_checkint' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 33, "message": "Variable 'l' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 67, "message": "Argument to 'isalnum()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isalnum((unsigned char)...)'"}, {"column": 40, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 70, "message": "Argument to 'isdigit()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isdigit((unsigned char)...)'"}, {"column": 43, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 72, "message": "Argument to 'toupper()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'toupper((unsigned char)...)'"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 76, "message": "Argument to 'isalnum()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isalnum((unsigned char)...)'"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 92, "message": "Variable 'l' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 32, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 163, "message": "Function 'lua_rawlen' is called without prior declaration", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Declare the function before calling it or include the appropriate header"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 199, "message": "Macro parameter 'res' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'res' in parentheses: (res) instead of res"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 199, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ if (res == -1) break; })"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 199, "message": "Multistatement macro 'checkvalres' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 28, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 202, "message": "Array declaration 'opts[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 205, "message": "Array declaration 'optsnum[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 208, "message": "'opts' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 32, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 237, "message": "Array declaration 'params[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 240, "message": "Array declaration 'pnum[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 49, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 243, "message": "'params' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 280, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 348, "message": "Function returns pointer to local variable 'mode' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 356, "message": "'fname' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 41, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 356, "message": "'mode' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 55, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 371, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 55, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 371, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 398, "message": "Variable 'l' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 509, "message": "Array declaration 'base_funcs[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 540, "message": "Function 'luaopen_base' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 540, "message": "Function 'luaopen_base' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_base"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lbaselib.c", "line": 549, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 35, "message": "Function-like macro 'hasjumps' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 35, "message": "Macro evaluates parameter 'e' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 43, "message": "Function 'luaK_semerror' does not validate pointer parameter 'ls' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ls' at the start of the function, e.g., 'if (!ls) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 43, "message": "Function 'luaK_semerror' does not validate pointer parameter 'fmt' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fmt' at the start of the function, e.g., 'if (!fmt) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 43, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 46, "message": "Variable 'argp' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'argp' before use, e.g., at its declaration"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 75, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 85, "message": "Function 'luaK_exp2const' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 85, "message": "Function 'luaK_exp2const' does not validate pointer parameter 'v' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'v' at the start of the function, e.g., 'if (!v) { return error_code; }'"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 117, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 132, "message": "Function 'luaK_nil' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 132, "message": "Function 'luaK_nil' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 135, "message": "Potential null pointer dereference of variable 'previous'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'previous' is not NULL before dereferencing"}, {"column": 27, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 143, "message": "Pointer subtraction between pointers from different arrays: 'pl' and 'pfrom'", "rule_id": "ARR36-C", "severity": "High", "suggestion": "Ensure both pointers refer to the same array before subtraction"}, {"column": 31, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 155, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 156, "message": "Array subscript uses function parameter 'pc' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'pc' before using it as an array index"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 156, "message": "Potentially unsafe array access with unvalidated function parameter index 'pc'", "rule_id": "ARR30-C", "severity": "High", "suggestion": "Add bounds checking for function parameter before using as array index."}, {"column": 13, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 160, "message": "Pointer arithmetic on non-array pointer 'pc'. Only perform arithmetic on array pointers", "rule_id": "ARR37-C", "severity": "High", "suggestion": "Use array indexing or ensure pointer refers to an array"}, {"column": 32, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 168, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 169, "message": "Array subscript uses function parameter 'pc' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'pc' before using it as an array index"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 169, "message": "Potentially unsafe array access with unvalidated function parameter index 'pc'", "rule_id": "ARR30-C", "severity": "High", "suggestion": "Add bounds checking for function parameter before using as array index."}, {"column": 24, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 170, "message": "Pointer arithmetic on non-array pointer 'pc'. Only perform arithmetic on array pointers", "rule_id": "ARR37-C", "severity": "High", "suggestion": "Use array indexing or ensure pointer refers to an array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 182, "message": "Function 'luaK_concat' does not validate pointer parameter 'l1' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'l1' at the start of the function, e.g., 'if (!l1) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 200, "message": "Function 'luaK_jump' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 208, "message": "Function 'luaK_ret' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 208, "message": "Function 'luaK_ret' does not validate integer parameter 'nret' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'nret' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 234, "message": "Function 'luaK_getlabel' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 245, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 246, "message": "Variable 'pi' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const pi = ..."}, {"column": 5, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 250, "message": "Function returns pointer to local variable 'pi' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 263, "message": "Potential null pointer dereference of variable 'i'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'i' is not NULL before dereferencing"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 270, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 308, "message": "Function 'luaK_patchlist' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 314, "message": "Function 'luaK_patchtohere' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 384, "message": "Function 'luaK_code' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 399, "message": "Function 'luaK_codeABCk' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 32, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 402, "message": "Bitwise operator '&' used on signed operand 'k' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'k' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 407, "message": "Function 'luaK_codevABCk' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 410, "message": "Bitwise operator '&' used on signed operand 'k' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'k' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 418, "message": "Function 'luaK_codeABx' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 442, "message": "Bitwise operator '&' used on signed operand 'k' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'k' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 476, "message": "Function 'luaK_checkstack' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 476, "message": "Function 'luaK_checkstack' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 488, "message": "Function 'luaK_reserveregs' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 488, "message": "Function 'luaK_reserveregs' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 525, "message": "Pointer parameter 'e' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *e'"}, {"column": 46, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 535, "message": "Pointer parameter 'e1' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *e1'"}, {"column": 59, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 535, "message": "Pointer parameter 'e2' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *e2'"}, {"column": 50, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 702, "message": "Variable 'fi' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'fi' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 715, "message": "Function 'luaK_codecheckglobal' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 715, "message": "Function 'luaK_codecheckglobal' does not validate pointer parameter 'var' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'var' at the start of the function, e.g., 'if (!var) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 715, "message": "Function 'luaK_codecheckglobal' does not validate integer parameter 'k' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'k' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 757, "message": "Function 'luaK_setreturns' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 757, "message": "Function 'luaK_setreturns' does not validate pointer parameter 'e' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'e' at the start of the function, e.g., 'if (!e) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 757, "message": "Function 'luaK_setreturns' does not validate integer parameter 'nresults' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'nresults' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 792, "message": "Function 'luaK_setoneret' does not validate pointer parameter 'e' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'e' at the start of the function, e.g., 'if (!e) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 808, "message": "Function 'luaK_vapar2local' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 808, "message": "Function 'luaK_vapar2local' does not validate pointer parameter 'var' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'var' at the start of the function, e.g., 'if (!var) { return error_code; }'"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 808, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 819, "message": "Function 'luaK_dischargevars' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 819, "message": "Function 'luaK_dischargevars' does not validate pointer parameter 'e' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'e' at the start of the function, e.g., 'if (!e) { return error_code; }'"}, {"column": 48, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 846, "message": "Use-after-free: accessing freed pointer 'e->u.ind.t'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access freed memory."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 851, "message": "Double-free: 'e->u.ind.t' freed multiple times", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Set pointer to NULL after freeing to prevent double-free."}, {"column": 52, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 852, "message": "Use-after-free: accessing freed pointer 'e->u.ind.t'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access freed memory."}, {"column": 52, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 858, "message": "Use-after-free: accessing freed pointer 'e->u.ind.t'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access freed memory."}, {"column": 64, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 858, "message": "Use-after-free: accessing freed pointer 'e->u.ind.idx'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access freed memory."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 863, "message": "Double-free: 'e->u.ind.idx' freed multiple times", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Set pointer to NULL after freeing to prevent double-free."}, {"column": 51, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 864, "message": "Use-after-free: accessing freed pointer 'e->u.ind.t'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access freed memory."}, {"column": 63, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 864, "message": "Use-after-free: accessing freed pointer 'e->u.ind.idx'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access freed memory."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 999, "message": "Function 'luaK_exp2nextreg' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 999, "message": "Function 'luaK_exp2nextreg' does not validate pointer parameter 'e' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'e' at the start of the function, e.g., 'if (!e) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1003, "message": "Use-after-free: passing freed pointer 'e' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1011, "message": "Function 'luaK_exp2anyreg' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1011, "message": "Function 'luaK_exp2anyreg' does not validate pointer parameter 'e' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'e' at the start of the function, e.g., 'if (!e) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1043, "message": "Function 'luaK_exp2val' does not validate pointer parameter 'e' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'e' at the start of the function, e.g., 'if (!e) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1105, "message": "Function 'luaK_storevar' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1105, "message": "Function 'luaK_storevar' does not validate pointer parameter 'var' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'var' at the start of the function, e.g., 'if (!var) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1105, "message": "Function 'luaK_storevar' does not validate pointer parameter 'ex' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ex' at the start of the function, e.g., 'if (!ex) { return error_code; }'"}, {"column": 44, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1105, "message": "Pointer parameter 'var' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *var'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1109, "message": "Use-after-free: passing freed pointer 'ex' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1113, "message": "Variable 'e' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const e = ..."}, {"column": 15, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1113, "message": "Use-after-free: passing freed pointer 'ex' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1118, "message": "Use-after-free: passing freed pointer 'ex' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1122, "message": "Use-after-free: passing freed pointer 'ex' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1126, "message": "Use-after-free: passing freed pointer 'ex' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1134, "message": "Use-after-free: passing freed pointer 'ex' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1139, "message": "Double-free: 'ex' freed multiple times", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Set pointer to NULL after freeing to prevent double-free."}, {"column": 53, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1146, "message": "Pointer parameter 'e' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *e'"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1148, "message": "Potential null pointer dereference of variable 'pc'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'pc' is not NULL before dereferencing"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1171, "message": "Use-after-free: passing freed pointer 'e' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 43, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1171, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 43, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1171, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1178, "message": "Function 'luaK_goiftrue' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1178, "message": "Function 'luaK_goiftrue' does not validate pointer parameter 'e' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'e' at the start of the function, e.g., 'if (!e) { return error_code; }'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1249, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 19, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1249, "message": "Use-after-free: passing freed pointer 'e' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 47, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1249, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 47, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1249, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 16, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1256, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 29, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1256, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1257, "message": "Use-after-free: passing freed pointer 'e' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 20, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1257, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1258, "message": "Use-after-free: passing freed pointer 'e' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 20, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1258, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1321, "message": "Function 'luaK_self' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1321, "message": "Function 'luaK_self' does not validate pointer parameter 'e' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'e' at the start of the function, e.g., 'if (!e) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1321, "message": "Function 'luaK_self' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1326, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1357, "message": "Function 'luaK_indexed' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1357, "message": "Function 'luaK_indexed' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1357, "message": "Function 'luaK_indexed' does not validate pointer parameter 'k' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'k' at the start of the function, e.g., 'if (!k) { return error_code; }'"}, {"column": 36, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1419, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1443, "message": "Function 'binopr2op' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline binopr2op"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1443, "message": "Function 'binopr2op' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'binopr2op'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1454, "message": "Function 'unopr2op' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline unopr2op"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1454, "message": "Function 'unopr2op' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'unopr2op'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1463, "message": "Function 'binopr2TM' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline binopr2TM"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1463, "message": "Function 'binopr2TM' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'binopr2TM'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1475, "message": "Variable 'r' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const r = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1477, "message": "Use-after-free: accessing member of freed pointer 'e'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 23, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1566, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1643, "message": "Variable 'im' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'im' before use, e.g., at its declaration"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1679, "message": "Variable 'im' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'im' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1698, "message": "Function 'luaK_prefix' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1698, "message": "Function 'luaK_prefix' does not validate pointer parameter 'e' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'e' at the start of the function, e.g., 'if (!e) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1719, "message": "Function 'luaK_infix' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1719, "message": "Function 'luaK_infix' does not validate pointer parameter 'v' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'v' at the start of the function, e.g., 'if (!v) { return error_code; }'"}, {"column": 48, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1768, "message": "Pointer parameter 'e1' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *e1'"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1770, "message": "Potential null pointer dereference of variable 'ie2'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'ie2' is not NULL before dereferencing"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1797, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1803, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1808, "message": "Macro invocation 'codeconcat' may create universal character names through concatenation", "rule_id": "PRE30-C", "severity": "High", "suggestion": "Use complete universal character names instead of concatenating fragments"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1869, "message": "Function 'luaK_fixline' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1875, "message": "Function 'luaK_settablesize' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1875, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1876, "message": "Array subscript uses function parameter 'pc' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'pc' before using it as an array index"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1876, "message": "Potentially unsafe array access with unvalidated function parameter index 'pc'", "rule_id": "ARR30-C", "severity": "High", "suggestion": "Add bounds checking for function parameter before using as array index."}, {"column": 18, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1878, "message": "Modulo operator used with potentially signed operands. The result of % with negative operands is implementation-defined and can be negative. Use unsigned types (size_t, unsigned int) or explicitly handle negative remainders.", "rule_id": "INT10-C", "severity": "Medium", "suggestion": "Convert operands to unsigned types (size_t, unsigned int) or add explicit checks for negative values"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1882, "message": "Pointer arithmetic on non-array pointer 'inst'. Only perform arithmetic on array pointers", "rule_id": "ARR37-C", "severity": "High", "suggestion": "Use array indexing or ensure pointer refers to an array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1893, "message": "Function 'luaK_setlist' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1893, "message": "Function 'luaK_setlist' does not validate integer parameter 'base' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'base' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1912, "message": "Pointer parameter 'code' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *code'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1914, "message": "Loop uses uninitialized variable 'count' as bound for array access. This has indeterminate value and can cause out-of-bounds access.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Initialize 'count' to a valid value before using it in the loop"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1930, "message": "Function 'luaK_finish' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1933, "message": "Bitwise operator '&' used on signed operand 'p' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'p' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1933, "message": "Variable 'p' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1937, "message": "Pointer arithmetic on non-array pointer 'pc'. Only perform arithmetic on array pointers", "rule_id": "ARR37-C", "severity": "High", "suggestion": "Use array indexing or ensure pointer refers to an array"}, {"column": 4, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1938, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1940, "message": "Bitwise operator '&' used on signed operand 'p' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'p' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1948, "message": "Bitwise operator '&' used on signed operand 'p' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'p' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1953, "message": "Bitwise operator '&' used on signed operand 'p' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'p' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lcode.c", "line": 1958, "message": "Bitwise operator '&' used on signed operand 'p' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'p' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.h", "line": 60, "message": "Function-like macro 'luaK_jumpto' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.h", "line": 60, "message": "Macro evaluates parameter 'fs' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcode.h", "line": 102, "message": "Variadic function declaration should use proper header", "rule_id": "EXP37-C", "severity": "Medium", "suggestion": "Include proper header instead of declaring variadic function"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcorolib.c", "line": 25, "message": "Function returns pointer to local variable 'co' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lcorolib.c", "line": 35, "message": "Implicit boolean test on 'lua_checkstack(co, narg)'. May be unclear what constitutes success or failure.", "rule_id": "EXP20-C", "severity": "Medium", "suggestion": "Use explicit test: lua_checkstack(co, narg) == 0 or lua_checkstack(co, narg) != 0 depending on success convention"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lcorolib.c", "line": 42, "message": "Implicit boolean test on 'lua_checkstack(L, nres + 1)'. May be unclear what constitutes success or failure.", "rule_id": "EXP20-C", "severity": "Medium", "suggestion": "Use explicit test: lua_checkstack(L, nres + 1) == 0 or lua_checkstack(L, nres + 1) != 0 depending on success convention"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lcorolib.c", "line": 76, "message": "Variable 'r' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const r = ..."}, {"column": 26, "file": "/home/brandon/toolchain/lua/lcorolib.c", "line": 124, "message": "Array declaration 'statname[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lcorolib.c", "line": 128, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lcorolib.c", "line": 207, "message": "Array declaration 'co_funcs[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcorolib.c", "line": 221, "message": "Function 'luaopen_coroutine' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lcorolib.c", "line": 221, "message": "Function 'luaopen_coroutine' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_coroutine"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.c", "line": 28, "message": "Variable-length array with runtime-sized allocation; use malloc instead", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Use malloc/calloc for dynamic allocation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 58, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 71, "message": "Function-like macro 'ltolower' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 71, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp(('A' <= (c) && (c) <= 'Z') || (c) == ((c) | ('A' ^ 'a')), \\\n (c) | ('A' ^ 'a')))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 71, "message": "Macro evaluates parameter 'c' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 77, "message": "Declaration is missing an explicit type specifier", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Add an explicit type specifier to the declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 77, "message": "Fixed-size buffer may be used with environment variable", "rule_id": "ENV01-C", "severity": "High", "suggestion": "Use dynamic allocation based on strlen() of getenv() result"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 77, "message": "Variable-length array with runtime-sized allocation; use malloc instead", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Use malloc/calloc for dynamic allocation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 89, "message": "Function-like macro 'lislalpha' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 89, "message": "Macro evaluates parameter 'c' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 90, "message": "Function-like macro 'lislalnum' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lctype.h", "line": 90, "message": "Macro evaluates parameter 'c' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 29, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 37, "message": "Implicit boolean test on 'lua_checkstack(L1, n)'. May be unclear what constitutes success or failure.", "rule_id": "EXP20-C", "severity": "Medium", "suggestion": "Use explicit test: lua_checkstack(L1, n) == 0 or lua_checkstack(L1, n) != 0 depending on success convention"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 153, "message": "Variable 'L1' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const L1 = ..."}, {"column": 43, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 154, "message": "Variable 'arg' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'arg' before use, e.g., at its declaration"}, {"column": 43, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 154, "message": "Signed integer addition 'arg+2' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 39, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 156, "message": "Signed integer addition 'arg + 2' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 25, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 157, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 22, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 159, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 9, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 163, "message": "Implicit boolean test on 'lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar)'. May be unclear what constitutes success or failure.", "rule_id": "EXP20-C", "severity": "Medium", "suggestion": "Use explicit test: lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar) == 0 or lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar) != 0 depending on success convention"}, {"column": 53, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 163, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 29, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 169, "message": "Signed integer addition 'arg+2' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 14, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 171, "message": "Passing potentially null pointer 'options' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'options' is not NULL before passing to function"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 173, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 174, "message": "Passing string literal to function 'settabss' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 175, "message": "Passing string literal to function 'settabsi' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 176, "message": "Passing string literal to function 'settabsi' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 177, "message": "Passing string literal to function 'settabss' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 180, "message": "Passing string literal to function 'settabsi' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 182, "message": "Passing string literal to function 'settabsi' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 183, "message": "Passing string literal to function 'settabsi' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 184, "message": "Passing string literal to function 'settabsb' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 187, "message": "Passing string literal to function 'settabss' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 188, "message": "Passing string literal to function 'settabss' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 191, "message": "Passing string literal to function 'settabsi' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 192, "message": "Passing string literal to function 'settabsi' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 195, "message": "Passing string literal to function 'settabsb' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 196, "message": "Passing string literal to function 'settabsi' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 208, "message": "Variable 'L1' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const L1 = ..."}, {"column": 40, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 209, "message": "Variable 'arg' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'arg' before use, e.g., at its declaration"}, {"column": 40, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 209, "message": "Signed integer addition 'arg + 2' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 25, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 210, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 22, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 211, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 43, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 218, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 31, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 220, "message": "Signed integer addition 'arg+1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 240, "message": "Variable 'L1' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const L1 = ..."}, {"column": 41, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 242, "message": "Variable 'arg' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'arg' before use, e.g., at its declaration"}, {"column": 41, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 242, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 40, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 243, "message": "Signed integer addition 'arg + 2' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 29, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 245, "message": "Signed integer addition 'arg+1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 20, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 246, "message": "Signed integer addition 'arg+3' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 17, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 247, "message": "Signed integer addition 'arg+3' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 297, "message": "Function returns pointer to local variable 'id' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 25, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 317, "message": "Variable 'n1' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'n1' before use, e.g., at its declaration"}, {"column": 32, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 317, "message": "Variable 'n2' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'n2' before use, e.g., at its declaration"}, {"column": 28, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 327, "message": "Array declaration 'hooknames[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 360, "message": "Bitwise operator '&' used on signed operand 'mask' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'mask' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 361, "message": "Bitwise operator '&' used on signed operand 'mask' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'mask' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 362, "message": "Bitwise operator '&' used on signed operand 'mask' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'mask' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 371, "message": "Variable 'L1' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const L1 = ..."}, {"column": 26, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 372, "message": "Variable 'arg' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'arg' before use, e.g., at its declaration"}, {"column": 26, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 372, "message": "Signed integer addition 'arg+1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 19, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 373, "message": "Signed integer addition 'arg+1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 45, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 377, "message": "Signed integer addition 'arg+2' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 23, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 378, "message": "Signed integer addition 'arg+1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 37, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 379, "message": "Signed integer addition 'arg + 3' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 385, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 20, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 391, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 400, "message": "Variable 'L1' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const L1 = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 423, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 9, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 427, "message": "fgets() without truncation check. Input may be silently truncated.", "rule_id": "FIO20-C", "severity": "Medium", "suggestion": "Check for newline character to detect truncation: if (strchr(buf, '\\n') == NULL) { /* handle truncation */ }"}, {"column": 16, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 428, "message": "Variable 'buffer' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'buffer' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 440, "message": "Variable 'L1' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const L1 = ..."}, {"column": 37, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 441, "message": "Variable 'arg' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'arg' before use, e.g., at its declaration"}, {"column": 37, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 441, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 42, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 442, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 22, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 443, "message": "Signed integer addition 'arg + 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 41, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 445, "message": "Signed integer addition 'arg + 2' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b > 0 && a > INT_MAX - b) || (b < 0 && a < INT_MIN - b)) { /* handle error */ }"}, {"column": 23, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 452, "message": "Array declaration 'dblib[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 473, "message": "Function 'luaopen_debug' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldblib.c", "line": 473, "message": "Function 'luaopen_debug' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_debug"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 34, "message": "Function-like macro 'LuaClosure' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 34, "message": "Macro evaluates parameter 'f' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 85, "message": "Function 'luaG_getfuncline' does not validate integer parameter 'pc' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'pc' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 133, "message": "Function 'lua_sethook' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 133, "message": "Function 'lua_sethook' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_sethook"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 147, "message": "Function 'lua_gethook' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 147, "message": "Function 'lua_gethook' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_gethook"}, {"column": 41, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 147, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 152, "message": "Function 'lua_gethookmask' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 152, "message": "Function 'lua_gethookmask' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_gethookmask"}, {"column": 40, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 152, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 157, "message": "Function 'lua_gethookcount' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 157, "message": "Function 'lua_gethookcount' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_gethookcount"}, {"column": 41, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 157, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 162, "message": "Function 'lua_getstack' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 162, "message": "Function 'lua_getstack' does not validate pointer parameter 'ar' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ar' at the start of the function, e.g., 'if (!ar) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 162, "message": "Function 'lua_getstack' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_getstack"}, {"column": 41, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 186, "message": "Pointer parameter 'ci' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ci'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 198, "message": "Function 'luaG_findlocal' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 198, "message": "Function 'luaG_findlocal' does not validate pointer parameter 'ci' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"}, {"column": 39, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 198, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 222, "message": "Function 'lua_getlocal' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 222, "message": "Function 'lua_getlocal' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 6, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 225, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 240, "message": "Function returns pointer to local variable 'name' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 244, "message": "Function 'lua_setlocal' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 244, "message": "Function 'lua_setlocal' does not validate pointer parameter 'ar' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ar' at the start of the function, e.g., 'if (!ar) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 244, "message": "Function 'lua_setlocal' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 255, "message": "Function returns pointer to local variable 'name' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 285, "message": "Array subscript uses function parameter 'pc' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'pc' before using it as an array index"}, {"column": 26, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 286, "message": "Array subscript uses function parameter 'pc' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'pc' before using it as an array index"}, {"column": 16, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 300, "message": "Memory allocated with 'luaH_new' for variable 't' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(t)' before the variable goes out of scope"}, {"column": 56, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 323, "message": "Pointer parameter 'ci' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ci'"}, {"column": 12, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 326, "message": "Static variable 'funcnamefromcall' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'funcnamefromcall' before use, e.g., at its declaration"}, {"column": 4, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 335, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 395, "message": "Function 'lua_getinfo' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 395, "message": "Function 'lua_getinfo' does not validate pointer parameter 'what' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'what' at the start of the function, e.g., 'if (!what) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 395, "message": "Function 'lua_getinfo' does not validate pointer parameter 'ar' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ar' at the start of the function, e.g., 'if (!ar) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 395, "message": "Function 'lua_getinfo' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_getinfo"}, {"column": 29, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 447, "message": "Array subscript uses function parameter 'lastpc' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'lastpc' before using it as an array index"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 495, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 495, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 499, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 499, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 508, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 508, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 512, "message": "Variable(s) 'pc' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 9, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 524, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 9, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 524, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 542, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 542, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 11, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 562, "message": "Variable 'name' may be used uninitialized (not assigned on all paths)", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'name' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 573, "message": "Function returns pointer to local variable 'kind' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 9, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 589, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 9, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 589, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 624, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 624, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 651, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 651, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 662, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 662, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 666, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 666, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 30, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 685, "message": "Pointer parameter 'ci' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ci'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 703, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 707, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 707, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 6, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 717, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 33, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 739, "message": "Passing null pointer 'name' to 'formatvarinfo' which does not check for NULL", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'name' is not NULL before passing to 'formatvarinfo'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 746, "message": "Function 'typeerror' participates in indirect recursion: typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 746, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 757, "message": "Function 'luaG_typeerror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 757, "message": "Function 'luaG_typeerror' does not validate pointer parameter 'o' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'o' at the start of the function, e.g., 'if (!o) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 757, "message": "Function 'luaG_typeerror' does not validate pointer parameter 'op' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'op' at the start of the function, e.g., 'if (!op) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 757, "message": "Function 'luaG_typeerror' participates in indirect recursion: luaG_typeerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaV_finishget -> luaG_typeerror", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 757, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 767, "message": "Function 'luaG_callerror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 767, "message": "Function 'luaG_callerror' does not validate pointer parameter 'o' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'o' at the start of the function, e.g., 'if (!o) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 767, "message": "Function 'luaG_callerror' participates in indirect recursion: luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 767, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 22, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 770, "message": "Static variable 'funcnamefromcall' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'funcnamefromcall' before use, e.g., at its declaration"}, {"column": 53, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 771, "message": "Passing null pointer 'name' to 'formatvarinfo' which does not check for NULL", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'name' is not NULL before passing to 'formatvarinfo'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 776, "message": "Function 'luaG_forerror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 776, "message": "Function 'luaG_forerror' does not validate pointer parameter 'o' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'o' at the start of the function, e.g., 'if (!o) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 776, "message": "Function 'luaG_forerror' does not validate pointer parameter 'what' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'what' at the start of the function, e.g., 'if (!what) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 776, "message": "Function 'luaG_forerror' participates in indirect recursion: luaG_forerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> forprep -> forlimit -> luaG_forerror", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 776, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 782, "message": "Function 'luaG_concaterror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 782, "message": "Function 'luaG_concaterror' does not validate pointer parameter 'p1' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p1' at the start of the function, e.g., 'if (!p1) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 782, "message": "Function 'luaG_concaterror' participates in indirect recursion: luaG_concaterror -> luaG_typeerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaV_concat -> luaT_tryconcatTM -> luaG_concaterror", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 782, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 788, "message": "Function 'luaG_opinterror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 788, "message": "Function 'luaG_opinterror' does not validate pointer parameter 'p2' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p2' at the start of the function, e.g., 'if (!p2) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 788, "message": "Function 'luaG_opinterror' does not validate pointer parameter 'msg' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'msg' at the start of the function, e.g., 'if (!msg) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 788, "message": "Function 'luaG_opinterror' participates in indirect recursion: luaG_opinterror -> luaG_typeerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_trybiniTM -> luaT_trybinassocTM -> luaT_trybinTM -> luaG_opinterror", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 788, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 799, "message": "Function 'luaG_tointerror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 799, "message": "Function 'luaG_tointerror' does not validate pointer parameter 'p2' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p2' at the start of the function, e.g., 'if (!p2) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 799, "message": "Function 'luaG_tointerror' participates in indirect recursion: luaG_tointerror -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_trybiniTM -> luaT_trybinassocTM -> luaT_trybinTM -> luaG_tointerror", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 799, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 807, "message": "Function 'luaG_ordererror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 807, "message": "Function 'luaG_ordererror' does not validate pointer parameter 'p1' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p1' at the start of the function, e.g., 'if (!p1) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 807, "message": "Function 'luaG_ordererror' does not validate pointer parameter 'p2' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p2' at the start of the function, e.g., 'if (!p2) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 807, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 14, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 810, "message": "Passing potentially null pointer 't1' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 't1' is not NULL before passing to function"}, {"column": 18, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 810, "message": "Passing potentially null pointer 't2' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 't2' is not NULL before passing to function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 817, "message": "Function 'luaG_errnnil' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 817, "message": "Function 'luaG_errnnil' does not validate pointer parameter 'cl' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'cl' at the start of the function, e.g., 'if (!cl) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 817, "message": "Function 'luaG_errnnil' participates in indirect recursion: luaG_errnnil -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaG_errnnil", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 817, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 46, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 817, "message": "Pointer parameter 'cl' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *cl'"}, {"column": 6, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 828, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 28, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 834, "message": "Variable 'idlen' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'idlen' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 840, "message": "Function 'luaG_errormsg' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 840, "message": "Function 'luaG_errormsg' participates in indirect recursion: luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 840, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 857, "message": "Function 'luaG_runerror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 857, "message": "Function 'luaG_runerror' does not validate pointer parameter 'fmt' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fmt' at the start of the function, e.g., 'if (!fmt) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 857, "message": "Function 'luaG_runerror' participates in indirect recursion: luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 857, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 19, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 862, "message": "Variable 'argp' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'argp' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 910, "message": "Function 'luaG_tracecall' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.c", "line": 936, "message": "Function 'luaG_traceexec' does not validate pointer parameter 'pc' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'pc' at the start of the function, e.g., 'if (!pc) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.h", "line": 21, "message": "Function-like macro 'resethookcount' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.h", "line": 21, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.h", "line": 21, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldebug.h", "line": 57, "message": "Variadic function declaration should use proper header", "rule_id": "EXP37-C", "severity": "Medium", "suggestion": "Include proper header instead of declaring variadic function"}, {"column": 59, "file": "/home/brandon/toolchain/lua/ldebug.h", "line": 59, "message": "Pointer parameter 'src' should likely be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Consider declaring parameter as 'const <type> *src'"}, {"column": 33, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 81, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 49, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 81, "message": "Pointer parameter 'c' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *c'"}, {"column": 67, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 81, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 99, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (if (_setjmp((c)->b) == 0) ((f)(L, ud)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 105, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (if (setjmp((c)->b) == 0) ((f)(L, ud)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 112, "message": "Function 'luaD_seterrorobj' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 125, "message": "Function 'luaD_throw' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 125, "message": "Recursive function can cause excessive stack allocation", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Consider iterative approach or limit recursion depth"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 125, "message": "Function 'luaD_throw' calls itself directly (direct recursion)", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to use iteration instead of recursion"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 125, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 131, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 144, "message": "Function 'luaD_throw' calls 'abort', which dictates error handling. Application-independent code should report errors to the caller (via return values, error parameters, or error indicators) rather than terminating the program.", "rule_id": "ERR05-C", "severity": "Medium", "suggestion": "Replace 'abort' with error reporting via return value (e.g., 'return ERROR_CODE;'), error parameter (e.g., '*err = ERROR_CODE;'), or global error indicator"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 150, "message": "Function 'luaD_throwbaselevel' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 150, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 160, "message": "Function 'luaD_rawrunprotected' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 160, "message": "Function 'luaD_rawrunprotected' does not validate pointer parameter 'ud' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ud' at the start of the function, e.g., 'if (!ud) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 215, "message": "Function 'luaD_errerr' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 215, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 228, "message": "Function 'luaD_checkminstack' participates in indirect recursion: luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 228, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 330, "message": "Function 'luaD_reallocstack' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 330, "message": "Function 'luaD_reallocstack' does not validate integer parameter 'newsize' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'newsize' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 341, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 343, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 343, "message": "Use-after-free: passing freed pointer 'oldstack' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 345, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 349, "message": "Use-after-free: passing freed pointer 'oldstack' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 361, "message": "Function 'luaD_growstack' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 361, "message": "Function 'luaD_growstack' participates in indirect recursion: luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 19, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 373, "message": "Variable 'size' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 27, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 373, "message": "Bitwise operator '>>' used on signed operand 'size' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'size' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 386, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 34, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 395, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 419, "message": "Function 'luaD_shrinkstack' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 430, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 441, "message": "Function 'luaD_hook' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 478, "message": "Function 'luaD_hookcall' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 478, "message": "Function 'luaD_hookcall' does not validate pointer parameter 'ci' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 497, "message": "Variable 'L' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 11, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 503, "message": "Variable 'p' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 511, "message": "Variable(s) 'ci' modified and accessed in unsequenced function arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification from the function call"}, {"column": 13, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 511, "message": "Assignment in if statement condition: 'ci = ci->previous'", "rule_id": "EXP45-C", "severity": "Medium", "suggestion": "Use == for comparison, or move assignment outside if condition"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 525, "message": "Function 'tryfuncTM' participates in indirect recursion: tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 8, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 535, "message": "Variable 'status' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 10, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 537, "message": "Variable 'CIST_CCMT' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 542, "message": "Function 'genmoveresults' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 542, "message": "Function 'genmoveresults' does not validate integer parameter 'wanted' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'wanted' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 542, "message": "Function 'genmoveresults' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline genmoveresults"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 542, "message": "Function 'genmoveresults' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'genmoveresults'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 563, "message": "Function 'moveresults' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 563, "message": "Function 'moveresults' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline moveresults"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 563, "message": "Function 'moveresults' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'moveresults'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 563, "message": "Function 'moveresults' participates in indirect recursion: moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 607, "message": "Function 'luaD_poscall' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 607, "message": "Function 'luaD_poscall' does not validate pointer parameter 'ci' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 607, "message": "Function 'luaD_poscall' participates in indirect recursion: luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 621, "message": "Function-like macro 'next_ci' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 621, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 621, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 630, "message": "Function 'prepCallInfo' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 630, "message": "Function 'prepCallInfo' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline prepCallInfo"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 637, "message": "Function returns pointer to local variable 'ci' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 644, "message": "Function 'precallC' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 644, "message": "Function 'precallC' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline precallC"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 644, "message": "Function 'precallC' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'precallC'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 644, "message": "Function 'precallC' participates in indirect recursion: precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 32, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 650, "message": "Variable 'L' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 14, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 651, "message": "Potential null pointer dereference in member access of variable 'ci'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'ci' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 671, "message": "Function 'luaD_pretailcall' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 671, "message": "Function 'luaD_pretailcall' does not validate pointer parameter 'ci' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 671, "message": "Function 'luaD_pretailcall' does not validate integer parameter 'narg1' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'narg1' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 671, "message": "Function 'luaD_pretailcall' does not validate integer parameter 'delta' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'delta' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 671, "message": "Function 'luaD_pretailcall' participates in indirect recursion: luaD_pretailcall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaV_execute -> luaD_pretailcall", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 671, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 717, "message": "Function 'luaD_precall' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 717, "message": "Function 'luaD_precall' does not validate integer parameter 'nresults' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'nresults' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 717, "message": "Function 'luaD_precall' participates in indirect recursion: luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 717, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 736, "message": "Potential null pointer dereference in member access of variable 'ci'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'ci' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 759, "message": "Function 'ccall' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 759, "message": "Function 'ccall' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline ccall"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 759, "message": "Function 'ccall' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'ccall'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 759, "message": "Function 'ccall' participates in indirect recursion: ccall -> luaE_checkcstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 767, "message": "Potential null pointer dereference in member access of variable 'ci'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'ci' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 777, "message": "Function 'luaD_call' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 777, "message": "Function 'luaD_call' participates in indirect recursion: luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 785, "message": "Function 'luaD_callnoyield' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 785, "message": "Function 'luaD_callnoyield' participates in indirect recursion: luaD_callnoyield -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod -> luaD_callnoyield", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 39, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 886, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 890, "message": "Function returns pointer to local variable 'ci' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 40, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 918, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 968, "message": "Function 'lua_resume' does not validate pointer parameter 'from' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'from' at the start of the function, e.g., 'if (!from) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 968, "message": "Function 'lua_resume' does not validate pointer parameter 'nresults' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'nresults' at the start of the function, e.g., 'if (!nresults) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 968, "message": "Function 'lua_resume' does not validate integer parameter 'nargs' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'nargs' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 968, "message": "Function 'lua_resume' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_resume"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1003, "message": "Function 'lua_isyieldable' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1003, "message": "Function 'lua_isyieldable' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_isyieldable"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1008, "message": "Function 'lua_yieldk' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1008, "message": "Function 'lua_yieldk' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_yieldk"}, {"column": 43, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1051, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1061, "message": "Function 'luaD_closeprotected' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1061, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1083, "message": "Function 'luaD_pcall' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1083, "message": "Function 'luaD_pcall' does not validate pointer parameter 'u' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'u' at the start of the function, e.g., 'if (!u) { return error_code; }'"}, {"column": 42, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1129, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 12, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1137, "message": "Memory allocated with 'luaH_new' for variable 'anchor' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(anchor)' before the variable goes out of scope"}, {"column": 14, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1154, "message": "Potential null pointer dereference in member access of variable 'cl'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'cl' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1164, "message": "Function 'luaD_anchorobj' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1164, "message": "Function 'luaD_anchorobj' does not validate pointer parameter 'anchor' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'anchor' at the start of the function, e.g., 'if (!anchor) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1164, "message": "Function 'luaD_anchorobj' does not validate pointer parameter 'obj' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'obj' at the start of the function, e.g., 'if (!obj) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1166, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1173, "message": "Function 'luaD_protectedparser' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1173, "message": "Function 'luaD_protectedparser' does not validate pointer parameter 'z' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'z' at the start of the function, e.g., 'if (!z) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1173, "message": "Function 'luaD_protectedparser' does not validate pointer parameter 'name' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'name' at the start of the function, e.g., 'if (!name) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1173, "message": "Function 'luaD_protectedparser' does not validate pointer parameter 'mode' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'mode' at the start of the function, e.g., 'if (!mode) { return error_code; }'"}, {"column": 49, "file": "/home/brandon/toolchain/lua/ldo.c", "line": 1173, "message": "Pointer parameter 'z' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *z'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 31, "message": "Function-like macro 'condmovestack' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 31, "message": "Macro parameter 'pre' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'pre' in parentheses: (pre) instead of pre"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 31, "message": "Macro parameter 'pos' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'pos' in parentheses: (pos) instead of pos"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 31, "message": "Multistatement macro 'condmovestack' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 31, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 35, "message": "Function-like macro 'luaD_checkstackaux' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 35, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 35, "message": "Macro parameter 'pre' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'pre' in parentheses: (pre) instead of pre"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 35, "message": "Macro parameter 'pos' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'pos' in parentheses: (pos) instead of pos"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 35, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (if (l_unlikely(L->stack_last.p - L->top.p <= (n))) \\\n\t { pre; luaD_growstack(L, n, 1); pos; } \\\n\telse { condmovestack(L,pre,pos); })"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 35, "message": "Multistatement macro 'luaD_checkstackaux' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 35, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 45, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 46, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldo.h", "line": 46, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast(StkId, cast_charp(L->stack.p) + (n)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 42, "message": "Function-like macro 'dumpVector' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 42, "message": "Macro evaluates parameter 'v' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 44, "message": "Function-like macro 'dumpLiteral' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 44, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (dumpBlock(D,s,sizeof(s) - sizeof(char)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 44, "message": "Macro evaluates parameter 's' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 49, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 52, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 40, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 67, "message": "Division or modulo by 'align' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'align' is not zero before division"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 69, "message": "Shared variable 'paddingContent' lacks proper synchronization (not volatile or atomic). This may cause visibility issues across threads.", "rule_id": "CON03-C", "severity": "Medium", "suggestion": "Consider declaring the variable as 'volatile', using atomic types (atomic_int, etc.), or protecting access with mutexes"}, {"column": 14, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 73, "message": "Division or modulo by 'align' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'align' is not zero before division"}, {"column": 32, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 128, "message": "Variable 'x' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 32, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 128, "message": "Variable 'l_castS2U' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 6, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 144, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 19, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 159, "message": "Variable 'size' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'size' before use, e.g., at its declaration"}, {"column": 16, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 173, "message": "sizeof applied to pointer/array parameter 'f' which has decayed to a pointer", "rule_id": "ARR01-C", "severity": "High", "suggestion": "Do not use 'sizeof(f->code[0])'. Array/pointer parameters decay to pointers. Pass the array size as a separate parameter instead."}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 207, "message": "Function 'dumpProtos' participates in indirect recursion: dumpProtos -> dumpFunction -> dumpProtos", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 254, "message": "Function 'dumpFunction' participates in indirect recursion: dumpFunction -> dumpProtos -> dumpFunction", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 269, "message": "Function-like macro 'dumpNumInfo' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 269, "message": "Macro parameter 'tvar' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'tvar' in parentheses: (tvar) instead of tvar"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 269, "message": "Macro parameter 'value' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'value' in parentheses: (value) instead of value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 269, "message": "Multistatement macro 'dumpNumInfo' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 269, "message": "Macro evaluates parameter 'D' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 288, "message": "Function 'luaU_dump' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 288, "message": "Function 'luaU_dump' does not validate pointer parameter 'f' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'f' at the start of the function, e.g., 'if (!f) { return error_code; }'"}, {"column": 65, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 288, "message": "Pointer parameter 'data' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *data'"}, {"column": 9, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 291, "message": "Memory allocated with 'luaH_new' for variable 'D.h' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(D.h)' before the variable goes out of scope"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ldump.c", "line": 305, "message": "Memory leak: 'D.h' allocated with 'luaH_new' is not freed before return", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Free 'D.h' before this return statement"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 27, "message": "Function 'luaF_newCclosure' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 29, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 31, "message": "Function returns pointer to local variable 'c' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 35, "message": "Function 'luaF_newLclosure' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 35, "message": "Function 'luaF_newLclosure' does not validate integer parameter 'nupvals' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'nupvals' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 37, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 41, "message": "Function returns pointer to local variable 'c' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 48, "message": "Function 'luaF_initupvals' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 48, "message": "Function 'luaF_initupvals' does not validate pointer parameter 'cl' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'cl' at the start of the function, e.g., 'if (!cl) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 74, "message": "Local variable 'uv' assigned through pointer parameter - address will be invalid when function returns", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Copy data instead of assigning pointer, or use static/allocated storage"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 79, "message": "Function returns pointer to local variable 'uv' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 88, "message": "Pointer-to-pointer assignment may allow const circumvention: **pp = &L->openupval: '**pp = &L->openupval'", "rule_id": "EXP40-C", "severity": "Low", "suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 91, "message": "Variable(s) 'p' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 39, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 91, "message": "Variable 'p' may be used uninitialized (not assigned on all paths)", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'p' before use, e.g., at its declaration"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 94, "message": "Function returns pointer to local variable 'p' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 95, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 107, "message": "Function 'callclosemethod' participates in indirect recursion: callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 127, "message": "Function 'checkclosemth' participates in indirect recursion: checkclosemth -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaF_newtbcupval -> checkclosemth", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 145, "message": "Function 'prepcallclosemth' participates in indirect recursion: prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 172, "message": "Function 'luaF_newtbcupval' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 172, "message": "Function 'luaF_newtbcupval' participates in indirect recursion: luaF_newtbcupval -> checkclosemth -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaF_newtbcupval", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 186, "message": "Function 'luaF_unlinkupval' does not validate pointer parameter 'uv' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'uv' at the start of the function, e.g., 'if (!uv) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 197, "message": "Function 'luaF_closeupval' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 199, "message": "Variable(s) 'uv' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 49, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 199, "message": "Variable 'uv' may be used uninitialized (not assigned on all paths)", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'uv' before use, e.g., at its declaration"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 200, "message": "Potential null pointer dereference in member access of variable 'uv'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'uv' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 230, "message": "Function 'luaF_close' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 230, "message": "Function 'luaF_close' participates in indirect recursion: luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 243, "message": "Function 'luaF_newproto' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 266, "message": "Function returns pointer to local variable 'f' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 270, "message": "Function 'luaF_protosize' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 270, "message": "Pointer parameter 'p' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *p'"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 271, "message": "Scaled integer arithmetic with pointer: 'cast(lu_mem, sizeof(Proto))\n + cast_uint(p->sizep) * sizeof(Proto*)\n + cast_uint(p->sizek) * sizeof(TValue)\n + cast_uint(p->sizelocvars) * sizeof(LocVar)\n + cast_uint(p->sizeupvalues) * sizeof(Upvaldesc)'. This results in double scaling", "rule_id": "ARR39-C", "severity": "High", "suggestion": "Remove sizeof() or use unscaled integer arithmetic"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 271, "message": "Scaled integer arithmetic with pointer: 'cast(lu_mem, sizeof(Proto))\n + cast_uint(p->sizep) * sizeof(Proto*)\n + cast_uint(p->sizek) * sizeof(TValue)\n + cast_uint(p->sizelocvars) * sizeof(LocVar)'. This results in double scaling", "rule_id": "ARR39-C", "severity": "High", "suggestion": "Remove sizeof() or use unscaled integer arithmetic"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 271, "message": "Scaled integer arithmetic with pointer: 'cast(lu_mem, sizeof(Proto))\n + cast_uint(p->sizep) * sizeof(Proto*)\n + cast_uint(p->sizek) * sizeof(TValue)'. This results in double scaling", "rule_id": "ARR39-C", "severity": "High", "suggestion": "Remove sizeof() or use unscaled integer arithmetic"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 271, "message": "Variable 'p' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 285, "message": "Function 'luaF_freeproto' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 285, "message": "Function 'luaF_freeproto' does not validate pointer parameter 'f' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'f' at the start of the function, e.g., 'if (!f) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.c", "line": 303, "message": "Function 'luaF_getlocalname' does not validate pointer parameter 'f' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'f' at the start of the function, e.g., 'if (!f) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.h", "line": 22, "message": "Function-like macro 'isintwups' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.h", "line": 22, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.h", "line": 22, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.h", "line": 32, "message": "Function-like macro 'upisopen' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.h", "line": 32, "message": "Macro evaluates parameter 'up' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.h", "line": 35, "message": "Function-like macro 'uplevel' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lfunc.h", "line": 35, "message": "Macro evaluates parameter 'up' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 51, "message": "Function-like macro 'makewhite' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 51, "message": "Macro parameter 'x' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'x' in parentheses: (x) instead of x"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 51, "message": "Macro evaluates parameter 'x' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 55, "message": "Macro parameter 'x' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'x' in parentheses: (x) instead of x"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 59, "message": "Function-like macro 'set2black' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 59, "message": "Macro parameter 'x' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'x' in parentheses: (x) instead of x"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 59, "message": "Macro evaluates parameter 'x' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 63, "message": "Function-like macro 'valiswhite' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 63, "message": "Macro evaluates parameter 'x' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 65, "message": "Function-like macro 'keyiswhite' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 65, "message": "Macro evaluates parameter 'n' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 71, "message": "Function-like macro 'gcvalueN' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 71, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 77, "message": "Function-like macro 'gcvalarr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 77, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 81, "message": "Function-like macro 'markvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 81, "message": "Multistatement macro 'markvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 81, "message": "Macro evaluates parameter 'g' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 84, "message": "Function-like macro 'markkey' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 84, "message": "Multistatement macro 'markkey' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 84, "message": "Macro evaluates parameter 'n' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 86, "message": "Macro 'markobject' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 86, "message": "Function-like macro 'markobject' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 86, "message": "Multistatement macro 'markobject' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 86, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 92, "message": "Function-like macro 'markobjectN' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 92, "message": "Multistatement macro 'markobjectN' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 92, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 110, "message": "Function-like macro 'gnodelast' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 110, "message": "Macro evaluates parameter 'h' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 184, "message": "Function-like macro 'linkgclist' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 184, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 188, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 197, "message": "Function-like macro 'linkobjgclist' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 197, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 6, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 224, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 246, "message": "Function 'luaC_barrier_' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 247, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 268, "message": "Function 'luaC_barrierback_' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 269, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 282, "message": "Function 'luaC_fix' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 282, "message": "Function 'luaC_fix' does not validate pointer parameter 'o' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'o' at the start of the function, e.g., 'if (!o) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 283, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 297, "message": "Function 'luaC_newobjdt' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 297, "message": "Function 'luaC_newobjdt' does not validate integer parameter 'offset' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'offset' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 298, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 22, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 300, "message": "Scaled integer arithmetic with pointer: 'GCObject *, p + offset'. This results in double scaling", "rule_id": "ARR39-C", "severity": "High", "suggestion": "Remove sizeof() or use unscaled integer arithmetic"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 305, "message": "Function returns pointer to local variable 'o' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 312, "message": "Function 'luaC_newobj' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 408, "message": "Pointer-to-pointer assignment may allow const circumvention: **p = &g->twups: '**p = &g->twups'", "rule_id": "EXP40-C", "severity": "Low", "suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"}, {"column": 29, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 410, "message": "Potential null pointer dereference in member access of variable 'thread'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'thread' is not NULL before member access"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 470, "message": "Pointer parameter 'g' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *g'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 488, "message": "Identifier 'n' at line 488 is visually similar to 'h' at line 487 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 550, "message": "Identifier 'n' at line 550 is visually similar to 'h' at line 541 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 577, "message": "Identifier 'n' at line 577 is visually similar to 'h' at line 576 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 44, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 595, "message": "Pointer parameter 'h' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *h'"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 603, "message": "Use parentheses to clarify operator precedence: '((weakkey != NULL) << 1) | (weakvalue != NULL)'", "rule_id": "EXP00-C", "severity": "Low", "suggestion": "Add parentheses to enforce the intended order of operations"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 603, "message": "Use parentheses to clarify operator precedence: '((weakkey != NULL) << 1) | (weakvalue != NULL)'", "rule_id": "EXP00-C", "severity": "Low", "suggestion": "Add parentheses to enforce the intended order of operations"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 603, "message": "Do not use bitwise operator '|' with Boolean-like right operand '(weakvalue != NULL)'. Did you mean '||'?", "rule_id": "EXP46-C", "severity": "Low", "suggestion": "Replace bitwise operator '|' with logical operator '||' when working with Boolean values. Expression: ((weakkey != NULL) << 1) | (weakvalue != NULL)"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 603, "message": "Use parentheses to clarify operator precedence: '(weakkey != NULL) << 1'", "rule_id": "EXP00-C", "severity": "Low", "suggestion": "Add parentheses to enforce the intended order of operations"}, {"column": 58, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 672, "message": "Pointer parameter 'cl' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *cl'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 764, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 791, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 793, "message": "Identifier 'n' at line 793 is visually similar to 'h' at line 791 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 67, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 808, "message": "Pointer parameter 'f' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *f'"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 810, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 811, "message": "Identifier 'n' at line 811 is visually similar to 'h' at line 810 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 837, "message": "Declaration is missing an explicit type specifier", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Add an explicit type specifier to the declaration"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 875, "message": "Function '(*ts->falloc)' called with overlapping memory regions. If parameters are restrict-qualified, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure memory regions do not overlap when using restrict pointers"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 893, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 57, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 904, "message": "Bitwise operator '|' used on signed operand 'white' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'white' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 908, "message": "Use-after-free: dereferencing freed pointer 'p'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access memory after freeing it."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 920, "message": "Function returns pointer to local variable 'p' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 935, "message": "Pointer parameter 'g' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *g'"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 937, "message": "Floating-point division without error checking (consider using feclearexcept/fetestexcept)", "rule_id": "FLP03-C", "severity": "Low", "suggestion": "Use feclearexcept(FE_ALL_EXCEPT) before and fetestexcept(FE_ALL_EXCEPT) after floating-point operations"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 938, "message": "Floating-point division without error checking (consider using feclearexcept/fetestexcept)", "rule_id": "FLP03-C", "severity": "Low", "suggestion": "Use feclearexcept(FE_ALL_EXCEPT) before and fetestexcept(FE_ALL_EXCEPT) after floating-point operations"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 958, "message": "Function returns pointer to local variable 'o' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 969, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1000, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 38, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1009, "message": "Pointer parameter 'p' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *p'"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1025, "message": "Pointer-to-pointer assignment may allow const circumvention: **p = &g->finobj: '**p = &g->finobj'", "rule_id": "EXP40-C", "severity": "Low", "suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1026, "message": "Pointer-to-pointer assignment may allow const circumvention: **lastnext = findlast(&g->tobefnz): '**lastnext = findlast(&g->tobefnz)'", "rule_id": "EXP40-C", "severity": "Low", "suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1030, "message": "Potential null pointer dereference in member access of variable 'curr'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'curr' is not NULL before member access"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1035, "message": "Potential null pointer dereference of variable 'lastnext'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'lastnext' is not NULL before dereferencing"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1036, "message": "Local variable 'curr' assigned through pointer parameter - address will be invalid when function returns", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Copy data instead of assigning pointer, or use static/allocated storage"}, {"column": 50, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1046, "message": "Pointer parameter 'o' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *o'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1069, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1138, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 12, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1142, "message": "Potential null pointer dereference in member access of variable 'curr'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'curr' is not NULL before member access"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1173, "message": "Pointer parameter 'limit' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *limit'"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1175, "message": "Array declaration 'nextage[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1190, "message": "Potential null pointer dereference in member access of variable 'curr'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'curr' is not NULL before member access"}, {"column": 56, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1197, "message": "Bitwise operator '|' used on signed operand 'white' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'white' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1205, "message": "Local variable 'curr' assigned through pointer parameter - address will be invalid when function returns", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Copy data instead of assigning pointer, or use static/allocated storage"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1229, "message": "Potential null pointer dereference of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before dereferencing"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1239, "message": "Potential null pointer dereference in member access of variable 'curr'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'curr' is not NULL before member access"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1250, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1250, "message": "Potential null pointer dereference of variable 'next'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'next' is not NULL before dereferencing"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1251, "message": "Unreachable code after unconditional 'continue'.", "rule_id": "MSC07-C", "severity": "Low", "suggestion": "Remove the unreachable code or restructure the control flow"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1261, "message": "Pointer-to-pointer assignment may allow const circumvention: **list = correctgraylist(&g->grayagain): '**list = correctgraylist(&g->grayagain)'", "rule_id": "EXP40-C", "severity": "Low", "suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1262, "message": "Potential null pointer dereference of variable 'list'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'list' is not NULL before dereferencing"}, {"column": 48, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1276, "message": "Pointer parameter 'from' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *from'"}, {"column": 64, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1276, "message": "Pointer parameter 'to' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *to'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1292, "message": "Function 'finishgencycle' participates in indirect recursion: finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1356, "message": "Potential null pointer dereference of variable 'psurvival'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'psurvival' is not NULL before dereferencing"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1389, "message": "Function 'atomic2gen' participates in indirect recursion: atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1428, "message": "Function 'entergen' participates in indirect recursion: entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1440, "message": "Function 'luaC_changemode' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1441, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1458, "message": "Function 'fullgen' participates in indirect recursion: fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1471, "message": "Function 'checkmajorminor' participates in indirect recursion: checkmajorminor -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> luaC_runtilstate -> singlestep -> checkmajorminor", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1505, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 61, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1516, "message": "Pointer parameter 'limit' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *limit'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1530, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1544, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 52, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1589, "message": "Pointer parameter 'nextlist' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *nextlist'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1612, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (-3)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1613, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (-2)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1614, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (-1)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1617, "message": "Function 'singlestep' participates in indirect recursion: singlestep -> checkmajorminor -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> luaC_runtilstate -> singlestep", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1618, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1694, "message": "Function 'luaC_runtilstate' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1694, "message": "Function 'luaC_runtilstate' participates in indirect recursion: luaC_runtilstate -> singlestep -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> luaC_runtilstate", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1695, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 44, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1712, "message": "Division or modulo by 'cast_int(sizeof(void*))' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'cast_int(sizeof(void*))' is not zero before division"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1740, "message": "Function 'luaC_step' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1741, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1770, "message": "Function 'fullinc' participates in indirect recursion: fullinc -> luaC_runtilstate -> singlestep -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullinc", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1786, "message": "Function 'luaC_fullgc' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1786, "message": "Function 'luaC_fullgc' participates in indirect recursion: luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lgc.c", "line": 1787, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 46, "message": "Function-like macro 'issweepphase' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 46, "message": "Macro evaluates parameter 'g' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 70, "message": "Macro 'resetbit' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 71, "message": "Macro 'testbit' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 103, "message": "Function-like macro 'nw2black' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 103, "message": "Macro evaluates parameter 'x' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 106, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast_byte((g)->currentwhite & WHITEBITS))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 121, "message": "Function-like macro 'setage' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 121, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 204, "message": "Macro parameter 'g' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'g' in parentheses: (g) instead of g"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 204, "message": "Macro 'setgcparam' uses token concatenation operator (##) which prevents parameter expansion - consider using two-level macro indirection for proper expansion", "rule_id": "PRE05-C", "severity": "Low", "suggestion": "Use two-level indirection: define a wrapper macro that calls another macro with ##, allowing parameters to expand first"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 205, "message": "Macro parameter 'g' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'g' in parentheses: (g) instead of g"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 205, "message": "Macro 'applygcparam' uses token concatenation operator (##) which prevents parameter expansion - consider using two-level macro indirection for proper expansion", "rule_id": "PRE05-C", "severity": "Low", "suggestion": "Use two-level indirection: define a wrapper macro that calls another macro with ##, allowing parameters to expand first"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 229, "message": "Function-like macro 'condchangemem' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 229, "message": "Macro parameter 'pre' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'pre' in parentheses: (pre) instead of pre"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 229, "message": "Macro parameter 'pos' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'pos' in parentheses: (pos) instead of pos"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 229, "message": "Multistatement macro 'condchangemem' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 229, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 233, "message": "Function-like macro 'luaC_condGC' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 233, "message": "Macro parameter 'pre' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'pre' in parentheses: (pre) instead of pre"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 233, "message": "Macro parameter 'pos' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'pos' in parentheses: (pos) instead of pos"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 233, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ if (G(L)->GCdebt <= 0) { pre; luaC_step(L); pos;}; \\\n\t condchangemem(L,pre,pos,0); })"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 233, "message": "Multistatement macro 'luaC_condGC' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 233, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 241, "message": "Function-like macro 'luaC_objbarrier' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 241, "message": "Macro evaluates parameter 'p' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 245, "message": "Function-like macro 'luaC_barrier' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 245, "message": "Macro evaluates parameter 'v' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 248, "message": "Function-like macro 'luaC_objbarrierback' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 248, "message": "Macro evaluates parameter 'p' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 251, "message": "Function-like macro 'luaC_barrierback' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lgc.h", "line": 251, "message": "Macro evaluates parameter 'v' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 23, "file": "/home/brandon/toolchain/lua/linit.c", "line": 28, "message": "Array declaration 'stdlibs[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/linit.c", "line": 46, "message": "Function 'luaL_openselectedlibs' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/linit.c", "line": 46, "message": "Function 'luaL_openselectedlibs' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUALIB_API luaL_openselectedlibs"}, {"column": 16, "file": "/home/brandon/toolchain/lua/linit.c", "line": 51, "message": "Bitwise operator '&' used on signed operand 'mask' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'mask' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 24, "file": "/home/brandon/toolchain/lua/linit.c", "line": 55, "message": "Bitwise operator '&' used on signed operand 'mask' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'mask' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 15, "file": "/home/brandon/toolchain/lua/linit.c", "line": 60, "message": "Bitwise operator '>>' used on signed operand 'mask' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'mask' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 1, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 39, "message": "Function 'l_checkmode' performs compound operation on shared static variable 'mode' without synchronization", "rule_id": "CON07-C", "severity": "Medium", "suggestion": "Use mutex locks (mtx_lock/mtx_unlock) or atomic operations to ensure atomicity"}, {"column": 11, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 40, "message": "Variable(s) 'mode' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 11, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 40, "message": "Variable(s) 'mode' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 11, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 40, "message": "Variable(s) 'mode' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 11, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 41, "message": "Variable(s) 'mode' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 1, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 68, "message": "Function-like macro 'l_checkmodep' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 68, "message": "Macro parameter 'm' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'm' in parentheses: (m) instead of m"}, {"column": 1, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 68, "message": "Macro evaluates parameter 'm' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 88, "message": "Function-like macro 'l_checkmodep' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 88, "message": "Macro parameter 'm' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'm' in parentheses: (m) instead of m"}, {"column": 1, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 88, "message": "Macro evaluates parameter 'm' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 202, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 204, "message": "Function returns pointer to local variable 'p' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 254, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 256, "message": "Function returns pointer to local variable 'p' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 262, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 262, "message": "FILE pointer 'p->f' opened with fopen/freopen but never closed with fclose()", "rule_id": "FIO42-C", "severity": "High", "suggestion": "Add fclose(p->f) before function returns or program exits"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 262, "message": "File descriptor 'p->f' opened with open() but never closed with close()", "rule_id": "FIO42-C", "severity": "High", "suggestion": "Add close(p->f) before function returns or program exits"}, {"column": 10, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 262, "message": "File opened with fopen() but not closed with fclose()", "rule_id": "FIO51-C", "severity": "Medium", "suggestion": "Call fclose() before function returns"}, {"column": 56, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 264, "message": "Call to non-thread-safe function 'strerror'. Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting", "rule_id": "CON33-C", "severity": "Medium", "suggestion": "Use strerror_r() (POSIX) or strerror_s() (C11 Annex K) for thread-safe error reporting"}, {"column": 56, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 264, "message": "'strerror()' uses internal static storage that is shared between threads", "rule_id": "CON34-C", "severity": "Medium", "suggestion": "Use 'strerror_r' instead for thread safety"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 275, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 275, "message": "FILE pointer 'p->f' opened with fopen/freopen but never closed with fclose()", "rule_id": "FIO42-C", "severity": "High", "suggestion": "Add fclose(p->f) before function returns or program exits"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 275, "message": "File descriptor 'p->f' opened with open() but never closed with close()", "rule_id": "FIO42-C", "severity": "High", "suggestion": "Add close(p->f) before function returns or program exits"}, {"column": 10, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 275, "message": "Return value from fopen() should be checked for errors", "rule_id": "ERR00-C", "severity": "Medium", "suggestion": "Check if fopen() returned an error value (NULL, -1, etc.)"}, {"column": 10, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 275, "message": "File opened with fopen() but not closed with fclose()", "rule_id": "FIO51-C", "severity": "Medium", "suggestion": "Call fclose() before function returns"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 296, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 296, "message": "File descriptor 'p->f' opened with open() but never closed with close()", "rule_id": "FIO42-C", "severity": "High", "suggestion": "Add close(p->f) before function returns or program exits"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 305, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 10, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 305, "message": "tmpfile() creates temporary files in a shared directory (typically /tmp), which is vulnerable to race conditions and symlink attacks. Use mkstemp() in a secure directory instead.", "rule_id": "FIO21-C", "severity": "High", "suggestion": "Use mkstemp() with a template in a secure, user-specific directory"}, {"column": 10, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 316, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 17, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 468, "message": "Plain 'char' passed to 'isxdigit()' without cast to 'unsigned char'", "rule_id": "STR00-C", "severity": "Medium", "suggestion": "Cast to '(unsigned char)' before passing to 'isxdigit()': isxdigit((unsigned char)rn->c)"}, {"column": 26, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 468, "message": "Argument to 'isxdigit()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isxdigit((unsigned char)...)'"}, {"column": 35, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 468, "message": "Plain 'char' passed to 'isdigit()' without cast to 'unsigned char'", "rule_id": "STR00-C", "severity": "Medium", "suggestion": "Cast to '(unsigned char)' before passing to 'isdigit()': isdigit((unsigned char)rn->c)"}, {"column": 43, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 468, "message": "Argument to 'isdigit()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isdigit((unsigned char)...)'"}, {"column": 44, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 479, "message": "Pointer parameter 'f' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *f'"}, {"column": 38, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 488, "message": "Plain 'char' passed to 'isspace()' without cast to 'unsigned char'", "rule_id": "STR00-C", "severity": "Medium", "suggestion": "Cast to '(unsigned char)' before passing to 'isspace()': isspace((unsigned char)rn.c)"}, {"column": 46, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 488, "message": "Argument to 'isspace()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isspace((unsigned char)...)'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 501, "message": "Return value of 'ungetc' ignored: 'ungetc(rn.c, rn.f)' - Can return error indicator", "rule_id": "ERR33-C", "severity": "High", "suggestion": "Check return value for errors"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 514, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 515, "message": "Return value of 'ungetc' ignored: 'ungetc(c, f)' - Can return error indicator", "rule_id": "ERR33-C", "severity": "High", "suggestion": "Check return value for errors"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 525, "message": "EOF comparison without feof()/ferror() verification: 'do { /* may need to read several chunks to get whole line */'", "rule_id": "FIO34-C", "severity": "High", "suggestion": "After EOF is detected, call feof() and ferror() to distinguish between end-of-file and I/O error"}, {"column": 5, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 529, "message": "EOF comparison without feof()/ferror() verification: 'while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\\n')'", "rule_id": "FIO34-C", "severity": "High", "suggestion": "After EOF is detected, call feof() and ferror() to distinguish between end-of-file and I/O error"}, {"column": 12, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 529, "message": "Variable(s) 'c' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 61, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 529, "message": "Variable 'c' may be used uninitialized (not assigned on all paths)", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'c' before use, e.g., at its declaration"}, {"column": 24, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 538, "message": "Function 'lua_rawlen' is called without prior declaration", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Declare the function before calling it or include the appropriate header"}, {"column": 5, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 548, "message": "Return value of 'fread' assigned to 'nr' but not checked for errors: 'fread(p, sizeof(char), LUAL_BUFFERSIZE, f)' - Returns number of items read, may be less than requested", "rule_id": "ERR33-C", "severity": "High", "suggestion": "Check if (items_read == expected_items) or handle partial reads"}, {"column": 10, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 548, "message": "Return value from fread() should be checked for errors", "rule_id": "ERR00-C", "severity": "Medium", "suggestion": "Check if fread() returned an error value (NULL, -1, etc.)"}, {"column": 10, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 548, "message": "fread() used without explicitly accounting for null terminator in character buffer", "rule_id": "FIO17-C", "severity": "Medium", "suggestion": "Ensure buffer size accounts for null terminator, or explicitly add null terminator after fread()"}, {"column": 8, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 561, "message": "Return value from fread() should be checked for errors", "rule_id": "ERR00-C", "severity": "Medium", "suggestion": "Check if fread() returned an error value (NULL, -1, etc.)"}, {"column": 8, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 561, "message": "fread() used without explicitly accounting for null terminator in character buffer", "rule_id": "FIO17-C", "severity": "Medium", "suggestion": "Ensure buffer size accounts for null terminator, or explicitly add null terminator after fread()"}, {"column": 14, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 561, "message": "Passing potentially null pointer 'p' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before passing to function"}, {"column": 8, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 589, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 17, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 642, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 10, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 668, "message": "Variable 'buff' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'buff' before use, e.g., at its declaration"}, {"column": 16, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 678, "message": "fwrite() count argument 'len' not derived from strlen(s). May write incorrect number of bytes.", "rule_id": "FIO18-C", "severity": "Medium", "suggestion": "For null-terminated strings, use strlen(s) + 1 to include the null terminator but avoid writing uninitialized data."}, {"column": 23, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 678, "message": "Passing potentially null pointer 's' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before passing to function"}, {"column": 20, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 703, "message": "Array declaration 'mode[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 28, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 704, "message": "Array declaration 'modenames[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 42, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 706, "message": "'modenames' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 20, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 723, "message": "Array declaration 'mode[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 28, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 724, "message": "Array declaration 'modenames[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 41, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 726, "message": "'modenames' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 23, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 754, "message": "Array declaration 'iolib[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 23, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 773, "message": "Array declaration 'meth[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 23, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 788, "message": "Array declaration 'metameth[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 802, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 47, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 819, "message": "Pointer parameter 'f' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *f'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 822, "message": "Potential null pointer dereference in member access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 832, "message": "Function 'luaopen_io' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/liolib.c", "line": 832, "message": "Function 'luaopen_io' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_io"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ljumptab.h", "line": 1, "message": "Header file missing include guard", "rule_id": "PRE06-C", "severity": "Low", "suggestion": "Add #ifndef HEADER_H / #define HEADER_H / #endif guard"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ljumptab.h", "line": 12, "message": "Macro parameter 'x' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'x' in parentheses: (x) instead of x"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ljumptab.h", "line": 12, "message": "Macro 'vmdispatch' definition ends with a semicolon. This can cause unexpected behavior when the macro is used.", "rule_id": "PRE11-C", "severity": "Medium", "suggestion": "Remove the trailing semicolon from the macro definition. The semicolon should be added by the macro user, not in the definition."}, {"column": 1, "file": "/home/brandon/toolchain/lua/ljumptab.h", "line": 14, "message": "Macro 'vmcase' uses token concatenation operator (##) which prevents parameter expansion - consider using two-level macro indirection for proper expansion", "rule_id": "PRE05-C", "severity": "Low", "suggestion": "Use two-level indirection: define a wrapper macro that calls another macro with ##, allowing parameters to expand first"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ljumptab.h", "line": 16, "message": "Multistatement macro 'vmbreak' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ljumptab.h", "line": 16, "message": "Macro 'vmbreak' definition ends with a semicolon. This can cause unexpected behavior when the macro is used.", "rule_id": "PRE11-C", "severity": "Medium", "suggestion": "Remove the trailing semicolon from the macro definition. The semicolon should be added by the macro user, not in the definition."}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 32, "message": "Function-like macro 'next' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 32, "message": "Macro parameter 'ls' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'ls' in parentheses: (ls) instead of ls"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 32, "message": "Macro evaluates parameter 'ls' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 41, "message": "Function-like macro 'currIsNewline' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 41, "message": "Macro parameter 'ls' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'ls' in parentheses: (ls) instead of ls"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 41, "message": "Macro evaluates parameter 'ls' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 26, "file": "/home/brandon/toolchain/lua/llex.c", "line": 45, "message": "Array declaration 'luaX_tokens []' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 56, "message": "Function-like macro 'save_and_next' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 56, "message": "Macro parameter 'ls' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'ls' in parentheses: (ls) instead of ls"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 56, "message": "Macro evaluates parameter 'ls' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 62, "message": "Function 'save' participates in indirect recursion: save -> lexerror -> txtToken -> save", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 5, "file": "/home/brandon/toolchain/lua/llex.c", "line": 68, "message": "Variable 'newsize' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 75, "message": "Function 'luaX_init' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/llex.c", "line": 77, "message": "Variable 'e' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const e = ..."}, {"column": 19, "file": "/home/brandon/toolchain/lua/llex.c", "line": 80, "message": "Memory allocated with 'luaS_new' for variable 'ts' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(ts)' before the variable goes out of scope"}, {"column": 5, "file": "/home/brandon/toolchain/lua/llex.c", "line": 82, "message": "Potential null pointer dereference in member access of variable 'ts'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'ts' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 87, "message": "Function 'luaX_token2str' does not validate pointer parameter 'ls' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ls' at the start of the function, e.g., 'if (!ls) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 87, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 38, "file": "/home/brandon/toolchain/lua/llex.c", "line": 87, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 14, "file": "/home/brandon/toolchain/lua/llex.c", "line": 99, "message": "Returning pointer to local array 's' which will be destroyed when function returns, creating a dangling pointer.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Consider allocating the array dynamically (malloc/calloc), declaring it as static, or passing a buffer as a parameter."}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 104, "message": "Function 'txtToken' participates in indirect recursion: txtToken -> save -> lexerror -> txtToken", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 116, "message": "Function 'lexerror' participates in indirect recursion: lexerror -> txtToken -> save -> lexerror", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 116, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 124, "message": "Function 'luaX_syntaxerror' does not validate pointer parameter 'ls' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ls' at the start of the function, e.g., 'if (!ls) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 124, "message": "Function 'luaX_syntaxerror' does not validate pointer parameter 'msg' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'msg' at the start of the function, e.g., 'if (!msg) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 124, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 37, "file": "/home/brandon/toolchain/lua/llex.c", "line": 135, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 156, "message": "Function 'luaX_newstring' does not validate pointer parameter 'ls' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ls' at the start of the function, e.g., 'if (!ls) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 156, "message": "Function 'luaX_newstring' does not validate pointer parameter 'str' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'str' at the start of the function, e.g., 'if (!str) { return error_code; }'"}, {"column": 51, "file": "/home/brandon/toolchain/lua/llex.c", "line": 156, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 176, "message": "Function 'luaX_setinput' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 176, "message": "Function 'luaX_setinput' does not validate pointer parameter 'ls' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ls' at the start of the function, e.g., 'if (!ls) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 176, "message": "Function 'luaX_setinput' does not validate pointer parameter 'z' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'z' at the start of the function, e.g., 'if (!z) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 176, "message": "Function 'luaX_setinput' does not validate pointer parameter 'source' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'source' at the start of the function, e.g., 'if (!source) { return error_code; }'"}, {"column": 53, "file": "/home/brandon/toolchain/lua/llex.c", "line": 176, "message": "Pointer parameter 'z' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *z'"}, {"column": 65, "file": "/home/brandon/toolchain/lua/llex.c", "line": 176, "message": "Pointer parameter 'source' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *source'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/llex.c", "line": 353, "message": "Variable 'r' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const r = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/llex.c", "line": 354, "message": "Variable 'r' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 8, "file": "/home/brandon/toolchain/lua/llex.c", "line": 354, "message": "Bitwise operator '<<' used on signed operand 'r' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'r' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 9, "file": "/home/brandon/toolchain/lua/llex.c", "line": 374, "message": "Variable 'r' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 10, "file": "/home/brandon/toolchain/lua/llex.c", "line": 374, "message": "Bitwise operator '<<' used on signed operand 'r' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'r' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 14, "file": "/home/brandon/toolchain/lua/llex.c", "line": 387, "message": "Reading from uninitialized array 'buff' inside a loop. Array was declared but never initialized before being read.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Initialize array 'buff' before reading: int buff[N] = {0}; or assign values before use"}, {"column": 14, "file": "/home/brandon/toolchain/lua/llex.c", "line": 387, "message": "Reading from 'buff' which may contain uninitialized data", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize the contents of 'buff' before reading"}, {"column": 3, "file": "/home/brandon/toolchain/lua/llex.c", "line": 393, "message": "Variable 'r' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const r = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 467, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 16, "file": "/home/brandon/toolchain/lua/llex.c", "line": 568, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 11, "file": "/home/brandon/toolchain/lua/llex.c", "line": 578, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 588, "message": "Function 'luaX_next' does not validate pointer parameter 'ls' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ls' at the start of the function, e.g., 'if (!ls) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llex.c", "line": 599, "message": "Function 'luaX_lookahead' does not validate pointer parameter 'ls' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ls' at the start of the function, e.g., 'if (!ls) { return error_code; }'"}, {"column": 39, "file": "/home/brandon/toolchain/lua/llex.h", "line": 85, "message": "Pointer parameter 'source' should likely be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Consider declaring parameter as 'const <type> *source'"}, {"column": 61, "file": "/home/brandon/toolchain/lua/llex.h", "line": 86, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 18, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast_int(sizeof(t) * CHAR_BIT))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 37, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast(l_mem, (cast(lu_mem, 1) << (l_numbits(l_mem) - 1)) - 1))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 65, "message": "Function-like macro 'ispow2' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 65, "message": "Macro evaluates parameter 'x' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 90, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast_uint((L_P2I)(p) & UINT_MAX))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 106, "message": "Macro parameter 'c' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'c' in parentheses: (c) instead of c"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 257, "message": "Function-like macro 'luai_nummod' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 257, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 257, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ (void)L; (m) = l_mathop(fmod)(a,b); \\\n if (((m) > 0) ? (b) < 0 : ((m) < 0 && (b) > 0)) (m) += (b); })"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 257, "message": "Multistatement macro 'luai_nummod' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 257, "message": "Macro evaluates parameter 'b' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 264, "message": "Function-like macro 'luai_numpow' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 264, "message": "Macro parameter 'b' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'b' in parentheses: (b) instead of b"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 264, "message": "Macro evaluates parameter 'a' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 279, "message": "Function-like macro 'luai_numisnan' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 279, "message": "Macro evaluates parameter 'a' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 293, "message": "Function-like macro 'lua_numbertointeger' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 293, "message": "Macro evaluates parameter 'n' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/llimits.h", "line": 322, "message": "Macro parameter 'dec' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'dec' in parentheses: (dec) instead of dec"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 83, "message": "Variable 'valid' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'valid' before use, e.g., at its declaration"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 132, "message": "Division or modulo by 'd' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'd' is not zero before division"}, {"column": 46, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 132, "message": "Modulo operator used with potentially signed operands. The result of % with negative operands is implementation-defined and can be negative. Use unsigned types (size_t, unsigned int) or explicitly handle negative remainders.", "rule_id": "INT10-C", "severity": "Medium", "suggestion": "Convert operands to unsigned types (size_t, unsigned int) or add explicit checks for negative values"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 135, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 192, "message": "Division or modulo by 'l_mathop(log)(base)' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'l_mathop(log)(base)' is not zero before division"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 206, "message": "Floating-point division without error checking (consider using feclearexcept/fetestexcept)", "rule_id": "FLP03-C", "severity": "Low", "suggestion": "Use feclearexcept(FE_ALL_EXCEPT) before and fetestexcept(FE_ALL_EXCEPT) after floating-point operations"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 206, "message": "Division or modulo by 'PI' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'PI' is not zero before division"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 212, "message": "Floating-point division without error checking (consider using feclearexcept/fetestexcept)", "rule_id": "FLP03-C", "severity": "Low", "suggestion": "Use feclearexcept(FE_ALL_EXCEPT) before and fetestexcept(FE_ALL_EXCEPT) after floating-point operations"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 212, "message": "Division or modulo by 'l_mathop(180.0)' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'l_mathop(180.0)' is not zero before division"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 221, "message": "Variable 'ep' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ep' before use, e.g., at its declaration"}, {"column": 6, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 307, "message": "Do not assume constant values in expressions: '(ULONG_MAX >> 31) >> 31'", "rule_id": "EXP07-C", "severity": "Low", "suggestion": "Use the constant identifier directly instead of assuming its numeric value"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 307, "message": "Do not assume constant values in expressions: 'ULONG_MAX >> 31'", "rule_id": "EXP07-C", "severity": "Low", "suggestion": "Use the constant identifier directly instead of assuming its numeric value"}, {"column": 8, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 319, "message": "Do not assume constant values in expressions: '(LUA_MAXUNSIGNED >> 31) >> 31'", "rule_id": "EXP07-C", "severity": "Low", "suggestion": "Use the constant identifier directly instead of assuming its numeric value"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 319, "message": "Do not assume constant values in expressions: 'LUA_MAXUNSIGNED >> 31'", "rule_id": "EXP07-C", "severity": "Low", "suggestion": "Use the constant identifier directly instead of assuming its numeric value"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 345, "message": "Variable 'n' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 345, "message": "Shift operation 'x << n' by 'n' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'n' is >= 0 and < the bit width of the operand before shifting"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 345, "message": "Bitwise operator '<<' used on signed operand 'n' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'n' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 345, "message": "Shift operation 'trim64(x) >> (64 - n)' by '(64 - n)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(64 - n)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 345, "message": "Bitwise operator '>>' used on signed operand 'n' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'n' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 352, "message": "Variable 'state1' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 356, "message": "Do not assume constant values in expressions: 'state1 << 17'", "rule_id": "EXP07-C", "severity": "Low", "suggestion": "Use the constant identifier directly instead of assuming its numeric value"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 431, "message": "Bitwise operator '|' used on signed operand 'i' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'i' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 431, "message": "Variable 'n' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 431, "message": "Shift operation 'i.h << n' by 'n' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'n' is >= 0 and < the bit width of the operand before shifting"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 431, "message": "Shift operation 'trim32(i.l) >> (32 - n)' by '(32 - n)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(32 - n)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 56, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 431, "message": "Bitwise operator '<<' used on signed operand 'i' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'i' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 56, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 431, "message": "Shift operation 'i.l << n' by 'n' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'n' is >= 0 and < the bit width of the operand before shifting"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 461, "message": "Bitwise operator '|' used on signed operand 'i' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'i' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 461, "message": "Variable 'n' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 461, "message": "Shift operation 'i.h << n' by 'n' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'n' is >= 0 and < the bit width of the operand before shifting"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 461, "message": "Shift operation 'trim32(i.l) >> (32 - n)' by '(32 - n)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(32 - n)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 462, "message": "Shift operation 'trim32(i.h) >> (32 - n)' by '(32 - n)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(32 - n)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 44, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 462, "message": "Bitwise operator '|' used on signed operand 'i' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'i' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 462, "message": "Shift operation 'i.l << n' by 'n' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'n' is >= 0 and < the bit width of the operand before shifting"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 468, "message": "Variable 'n' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 469, "message": "Bitwise operator '|' used on signed operand 'i' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'i' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 470, "message": "Bitwise operator '|' used on signed operand 'i' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'i' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 507, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 31, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 507, "message": "Variable 'FIGS' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 31, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 507, "message": "Shift operation 'trim32(x.h) >> (32 - FIGS)' by '(32 - FIGS)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(32 - FIGS)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 530, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 18, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 530, "message": "Variable 'x' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 530, "message": "Variable 'trim32' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 540, "message": "Do not assume constant values in expressions: '(lua_Unsigned)trim32(x.h) << 31'", "rule_id": "EXP07-C", "severity": "Low", "suggestion": "Use the constant identifier directly instead of assuming its numeric value"}, {"column": 27, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 545, "message": "Bitwise operator '>>' used on signed operand 'n' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'n' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 28, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 545, "message": "Do not assume constant values in expressions: 'n >> 31'", "rule_id": "EXP07-C", "severity": "Low", "suggestion": "Use the constant identifier directly instead of assuming its numeric value"}, {"column": 39, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 570, "message": "Pointer parameter 'state' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *state'"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 574, "message": "Variable 'lim' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 575, "message": "Shift operation 'lim >> sh' by 'sh' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'sh' is >= 0 and < the bit width of the operand before shifting"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 575, "message": "Bitwise operator '>>' used on signed operand 'sh' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'sh' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 586, "message": "Potential null pointer dereference in member access of variable 'state'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'state' is not NULL before member access"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 595, "message": "Variable 'up' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'up' before use, e.g., at its declaration"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 636, "message": "Potential null pointer dereference in member access of variable 'state'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'state' is not NULL before member access"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 647, "message": "Array declaration 'randfuncs[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 659, "message": "Potential null pointer dereference in member access of variable 'state'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'state' is not NULL before member access"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 706, "message": "Array declaration 'mathlib[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 752, "message": "Function 'luaopen_math' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 752, "message": "Function 'luaopen_math' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_math"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 755, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 757, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 759, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmathlib.c", "line": 761, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 47, "message": "Function-like macro 'callfrealloc' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 47, "message": "Macro parameter 'g' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'g' in parentheses: (g) instead of g"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 47, "message": "Macro evaluates parameter 'g' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 58, "message": "Function-like macro 'cantryagain' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 58, "message": "Macro parameter 'g' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'g' in parentheses: (g) instead of g"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 58, "message": "Macro evaluates parameter 'g' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 46, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 69, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 97, "message": "Function 'luaM_growaux_' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 97, "message": "Function 'luaM_growaux_' does not validate pointer parameter 'block' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'block' at the start of the function, e.g., 'if (!block) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 97, "message": "Function 'luaM_growaux_' does not validate pointer parameter 'psize' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'psize' at the start of the function, e.g., 'if (!psize) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 97, "message": "Function 'luaM_growaux_' does not validate integer parameter 'nelems' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'nelems' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 97, "message": "Function 'luaM_growaux_' does not validate integer parameter 'size_elems' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'size_elems' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 118, "message": "Function returns pointer to local variable 'newblock' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 128, "message": "Function 'luaM_shrinkvector_' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 128, "message": "Function 'luaM_shrinkvector_' does not validate pointer parameter 'block' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'block' at the start of the function, e.g., 'if (!block) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 128, "message": "Function 'luaM_shrinkvector_' does not validate pointer parameter 'size' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'size' at the start of the function, e.g., 'if (!size) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 128, "message": "Function 'luaM_shrinkvector_' does not validate integer parameter 'size_elem' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'size_elem' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 136, "message": "Function returns pointer to local variable 'newblock' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 142, "message": "Function 'luaM_toobig' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 142, "message": "Function 'luaM_toobig' participates in indirect recursion: luaM_toobig -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> luaM_toobig", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 142, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 150, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 151, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 43, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 162, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 164, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 41, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 176, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 178, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 188, "message": "Function returns pointer to local variable 'newblock' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 192, "message": "Function 'luaM_saferealloc_' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 192, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 196, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 5, "file": "/home/brandon/toolchain/lua/lmem.c", "line": 205, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 31, "message": "Function-like macro 'luaM_testsize' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 31, "message": "Macro evaluates parameter 'n' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 44, "message": "Function-like macro 'luaM_limitN' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 44, "message": "Macro evaluates parameter 'n' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 56, "message": "Function-like macro 'luaM_free' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 56, "message": "Macro evaluates parameter 'b' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 57, "message": "Function-like macro 'luaM_freearray' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 57, "message": "Macro evaluates parameter 'b' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 59, "message": "Function-like macro 'luaM_new' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 59, "message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 59, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 60, "message": "Function-like macro 'luaM_newvector' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 60, "message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 60, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 62, "message": "Function-like macro 'luaM_newvectorchecked' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 62, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 69, "message": "Function-like macro 'luaM_growvector' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 69, "message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 69, "message": "Macro evaluates parameter 'v' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 73, "message": "Function-like macro 'luaM_reallocvector' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 73, "message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 73, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 77, "message": "Function-like macro 'luaM_shrinkvector' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 77, "message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 77, "message": "Macro evaluates parameter 'v' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 51, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 83, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 55, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 85, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lmem.h", "line": 87, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 113, "message": "Function returns pointer to local variable 'lib' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 154, "message": "Fixed-size buffer may be used with environment variable", "rule_id": "ENV01-C", "severity": "High", "suggestion": "Use dynamic allocation based on strlen() of getenv() result"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 154, "message": "Variable-length array with runtime-sized allocation; use malloc instead", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Use malloc/calloc for dynamic allocation"}, {"column": 45, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 158, "message": "Variable 'buff' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'buff' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 161, "message": "Potential null pointer dereference of variable 'lb'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'lb' is not NULL before dereferencing"}, {"column": 5, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 161, "message": "Pointer dereference '*lb' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 34, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 216, "message": "Pointer parameter 'lib' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *lib'"}, {"column": 51, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 228, "message": "Pointer parameter 'lib' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *lib'"}, {"column": 22, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 279, "message": "'getenv()' uses internal static storage that is shared between threads", "rule_id": "CON34-C", "severity": "Medium", "suggestion": "Use 'secure_getenv or a cached copy' instead for thread safety"}, {"column": 5, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 281, "message": "Storing pointer returned by 'getenv' is prohibited. The data referenced may be overwritten by subsequent calls. Use strdup(), malloc()/strcpy(), or consume the value immediately.", "rule_id": "ENV34-C", "severity": "Medium", "suggestion": "Instead of 'ptr = getenv()', use 'ptr = strdup(getenv())' and remember to free() later, or use 'const char *ptr' for immediate use only"}, {"column": 12, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 281, "message": "'getenv()' uses internal static storage that is shared between threads", "rule_id": "CON34-C", "severity": "Medium", "suggestion": "Use 'secure_getenv or a cached copy' instead for thread safety"}, {"column": 25, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 287, "message": "'path' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 25, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 287, "message": "'path' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 33, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 291, "message": "Passing variable 'dftmark' (from 'getenv (derived)()') to function 'ct_diff2sz()' which may modify it.", "rule_id": "ENV30-C", "severity": "Medium", "suggestion": "Copy the return value to a local buffer before passing to functions that may modify it"}, {"column": 40, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 297, "message": "Passing variable 'path' (from 'getenv()') to function 'ct_diff2sz()' which may modify it.", "rule_id": "ENV30-C", "severity": "Medium", "suggestion": "Copy the return value to a local buffer before passing to functions that may modify it"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 328, "message": "Function returns pointer to local variable 'plib' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 28, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 336, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 38, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 336, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 38, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 336, "message": "Pointer parameter 'ptr' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ptr'"}, {"column": 11, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 387, "message": "Static variable 'lsys_load' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'lsys_load' before use, e.g., at its declaration"}, {"column": 29, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 408, "message": "'path' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 29, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 408, "message": "'path' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 35, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 408, "message": "'init' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 13, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 429, "message": "File opened for reading using variable filename 'filename' without verifying file attributes (fstat + st_uid/st_gid check)", "rule_id": "FIO05-C", "severity": "Medium", "suggestion": "Use fstat() to check file ownership (st_uid, st_gid) before reading untrusted files"}, {"column": 13, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 429, "message": "fopen() called without 'N' flag in mode string \"r\". On Windows, file handles are inheritable by default unless the 'N' flag is specified.", "rule_id": "WIN03-C", "severity": "High", "suggestion": "Add 'N' flag to the mode string (e.g., \"rwN\") to disable handle inheritance on Windows."}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 431, "message": "Return value from fclose() is ignored. Error handling is required.", "rule_id": "ERR00-C", "severity": "Medium", "suggestion": "Store and check the return value from fclose()"}, {"column": 55, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 441, "message": "Pointer parameter 'end' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *end'"}, {"column": 8, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 443, "message": "Pointer to const assigned to non-const pointer without cast: *name = *path: '*name = *path'", "rule_id": "EXP40-C", "severity": "Low", "suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"}, {"column": 16, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 443, "message": "Pointer dereference '*path' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 16, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 443, "message": "Pointer dereference '*path' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 447, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 5, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 447, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 453, "message": "Pointer dereference '*sep' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 454, "message": "Local variable 'sep' assigned through pointer parameter - address will be invalid when function returns", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Copy data instead of assigning pointer, or use static/allocated storage"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 454, "message": "Pointer dereference '*path' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 454, "message": "Pointer dereference '*path' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 455, "message": "Function returns pointer to local variable 'name' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 19, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 503, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 12, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 534, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 17, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 560, "message": "Passing potentially null pointer 'modname' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'modname' is not NULL before passing to function"}, {"column": 23, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 684, "message": "Array declaration 'pk_funcs[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 23, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 697, "message": "Array declaration 'll_funcs[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 30, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 704, "message": "Array declaration 'searchers[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 720, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 724, "message": "Function 'luaopen_package' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 724, "message": "Function 'luaopen_package' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_package"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 730, "message": "Passing string literal to function 'setpath' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 731, "message": "Passing string literal to function 'setpath' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 735, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 738, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loadlib.c", "line": 741, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 37, "message": "Function 'luaO_ceillog2' does not validate integer parameter 'x' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'x' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 50, "message": "Variable 'x' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 51, "message": "Array subscript uses function parameter 'x' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'x' before using it as an array index"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 63, "message": "Variable 'lu_mem' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 63, "message": "Variable 'cast' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 66, "message": "Variable 'p' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 74, "message": "Variable 'log' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 89, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 91, "message": "Variable 'e' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const e = ..."}, {"column": 5, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 94, "message": "Variable 'm' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 96, "message": "Variable 'e' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 98, "message": "Use parentheses to clarify operator precedence: '(MAX_LMEM / 0x1F) >> e'", "rule_id": "EXP00-C", "severity": "Low", "suggestion": "Add parentheses to enforce the intended order of operations"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 98, "message": "Variable 'MAX_LMEM' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 98, "message": "Bitwise operator '>>' used on signed operand 'e' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'e' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 99, "message": "Variable 'x' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 99, "message": "Bitwise operator '<<' used on signed operand 'e' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'e' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 106, "message": "Input operation on file stream '(x * m)' follows output without intervening positioning call (fflush, fseek, fsetpos, or rewind)", "rule_id": "FIO50-C", "severity": "Low", "suggestion": "Insert fflush() or a positioning function (fseek, fsetpos, rewind) between output and input operations"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 106, "message": "Input operation on file stream '(x * m)' follows output without intervening positioning call (fflush, fseek, fsetpos, or rewind)", "rule_id": "FIO50-C", "severity": "Low", "suggestion": "Insert fflush() or a positioning function (fseek, fsetpos, rewind) between output and input operations"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 106, "message": "Bitwise operator '>>' used on signed operand 'e' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'e' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 107, "message": "Bitwise operator '>>' used on signed operand 'e' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'e' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 108, "message": "Bitwise operator '>>' used on signed operand 'e' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'e' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 175, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 188, "message": "Function 'luaO_arith' does not validate integer parameter 'op' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'op' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 197, "message": "Function 'luaO_hexavalue' does not validate integer parameter 'c' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'c' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 199, "message": "Variable 'c' of type char used in numeric operation. Use explicit 'signed char' or 'unsigned char' for numeric values.", "rule_id": "INT07-C", "severity": "Medium", "suggestion": "Change declaration of 'c' from 'char' to 'signed char' or 'unsigned char'"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 199, "message": "Arithmetic expression involving 'c' (narrow type 'char') without proper overflow protection", "rule_id": "INT08-C", "severity": "Medium", "suggestion": "Use a wider type (e.g., 'long' instead of 'char') or add overflow checks before the operation"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 200, "message": "Arithmetic expression involving 'c' (narrow type 'char') without proper overflow protection", "rule_id": "INT08-C", "severity": "Medium", "suggestion": "Use a wider type (e.g., 'long' instead of 'char') or add overflow checks before the operation"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 230, "message": "Variable 'r' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const r = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 233, "message": "Variable 'e' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const e = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 236, "message": "Pointer dereference '*endptr' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 258, "message": "Pointer dereference '*endptr' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 271, "message": "Pointer dereference '*endptr' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 296, "message": "Potential null pointer dereference of variable 'endptr'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'endptr' is not NULL before dereferencing"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 317, "message": "'pmode' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 42, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 317, "message": "Pointer dereference '*pmode' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 43, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 317, "message": "'pmode' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 322, "message": "Fixed-size buffer may be used with environment variable", "rule_id": "ENV01-C", "severity": "High", "suggestion": "Use dynamic allocation based on strlen() of getenv() result"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 322, "message": "Variable-length array with runtime-sized allocation; use malloc instead", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Use malloc/calloc for dynamic allocation"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 326, "message": "Do not cast away const qualification: 's'", "rule_id": "EXP05-C", "severity": "Medium", "suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 330, "message": "Pointer subtraction between pointers from different arrays: 'param:s' and 'buff'", "rule_id": "ARR36-C", "severity": "High", "suggestion": "Ensure both pointers refer to the same array before subtraction"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 332, "message": "Function returns pointer to local variable 'endptr' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 336, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast(lua_Unsigned, LUA_MAXINTEGER / 10))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 337, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast_int(LUA_MAXINTEGER % 10))"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 355, "message": "Pointer dereference '*s' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 355, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 375, "message": "Variable 'i' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'i' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 386, "message": "Function 'luaO_utf8esc' does not validate pointer parameter 'buff' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'buff' at the start of the function, e.g., 'if (!buff) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 386, "message": "Function 'luaO_utf8esc' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static int luaO_utf8esc"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 386, "message": "Function 'luaO_utf8esc' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'luaO_utf8esc'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 395, "message": "Shift operation on signed integer 'x' may be used for arithmetic optimization (use explicit arithmetic instead)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use explicit arithmetic operations like * or / instead of shift operations on signed integers"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 429, "message": "'buff' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 449, "message": "Function 'luaO_tostringbuff' does not validate pointer parameter 'obj' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'obj' at the start of the function, e.g., 'if (!obj) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 464, "message": "Function 'luaO_tostring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 464, "message": "Function 'luaO_tostring' does not validate pointer parameter 'obj' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'obj' at the start of the function, e.g., 'if (!obj) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 484, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast_uint(LUA_IDSIZE + LUA_N2SBUFFSZ + 95))"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 500, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 503, "message": "sizeof applied to pointer/array parameter 'buff' which has decayed to a pointer", "rule_id": "ARR01-C", "severity": "High", "suggestion": "Do not use 'sizeof(buff->space)'. Array/pointer parameters decay to pointers. Pass the array size as a separate parameter instead."}, {"column": 42, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 513, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 521, "message": "Potential buffer overflow with strcpy(). Cannot verify destination buffer is large enough.", "rule_id": "STR31-C", "severity": "Medium", "suggestion": "Use strncpy() with explicit size limit or verify buffer size"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 523, "message": "Potential buffer overflow with strcpy(). Cannot verify destination buffer is large enough.", "rule_id": "STR31-C", "severity": "Medium", "suggestion": "Use strncpy() with explicit size limit or verify buffer size"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 545, "message": "Function returns pointer to local variable 'res' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 51, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 549, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 596, "message": "Function 'luaO_pushvfstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 596, "message": "Function 'luaO_pushvfstring' does not validate pointer parameter 'fmt' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fmt' at the start of the function, e.g., 'if (!fmt) { return error_code; }'"}, {"column": 63, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 596, "message": "Function takes 'va_list argp' by value and calls va_arg() on it. This makes the caller's va_list indeterminate after the function returns.", "rule_id": "MSC39-C", "severity": "Low", "suggestion": "Change parameter 'argp' to 'va_list *argp' and use va_copy() to create a local copy before calling va_arg()."}, {"column": 4, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 602, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 604, "message": "va_arg called with type 'char' which undergoes default argument promotion; use 'int' instead", "rule_id": "EXP47-C", "severity": "Medium", "suggestion": "Change va_arg type to 'int' and cast the result if needed: (char)va_arg(ap, int)"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 610, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 662, "message": "Function 'luaO_pushfstring' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 662, "message": "Function 'luaO_pushfstring' does not validate pointer parameter 'fmt' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fmt' at the start of the function, e.g., 'if (!fmt) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 670, "message": "Function returns pointer to local variable 'msg' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 680, "message": "Function-like macro 'addstr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 680, "message": "Macro parameter 'a' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'a' in parentheses: (a) instead of a"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 680, "message": "Macro evaluates parameter 'a' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 682, "message": "Function 'luaO_chunkid' does not validate pointer parameter 'out' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'out' at the start of the function, e.g., 'if (!out) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 682, "message": "Function 'luaO_chunkid' does not validate pointer parameter 'source' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'source' at the start of the function, e.g., 'if (!source) { return error_code; }'"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 682, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 42, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 682, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 686, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 689, "message": "Pointer dereference '*out' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 694, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 698, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 715, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lobject.c", "line": 715, "message": "memcpy() size argument contains arithmetic that may overflow: '(LL(POS) + 1) * sizeof(char)'", "rule_id": "INT32-C", "severity": "High", "suggestion": "Validate size calculations before passing to memory functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 98, "message": "Function-like macro 'righttt' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 98, "message": "Macro evaluates parameter 'obj' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 106, "message": "Function-like macro 'checkliveness' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 106, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 106, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 118, "message": "Multistatement macro 'setobj' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 221, "message": "Function-like macro 'isnonstrictnil' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 221, "message": "Macro evaluates parameter 'v' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 259, "message": "Function-like macro 'l_isfalse' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 259, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 260, "message": "Function-like macro 'tagisfalse' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 260, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 280, "message": "Function-like macro 'thvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 280, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 282, "message": "Multistatement macro 'setthvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 302, "message": "Multistatement macro 'CommonHeader' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 319, "message": "Function-like macro 'gcvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 319, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 323, "message": "Multistatement macro 'setgcovalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 344, "message": "Function-like macro 'nvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 344, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 346, "message": "Function-like macro 'fltvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 346, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 347, "message": "Function-like macro 'ivalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 347, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 352, "message": "Multistatement macro 'setfltvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 355, "message": "Multistatement macro 'chgfltvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 358, "message": "Multistatement macro 'setivalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 361, "message": "Multistatement macro 'chgivalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 383, "message": "Function-like macro 'tsvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 383, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 385, "message": "Multistatement macro 'setsvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 398, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (-1)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 399, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (-2)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 400, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (-3)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 422, "message": "Function-like macro 'isextstr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 422, "message": "Macro evaluates parameter 'ts' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 430, "message": "Function-like macro 'getshrstr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 430, "message": "Macro evaluates parameter 'ts' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 431, "message": "Function-like macro 'getlngstr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 431, "message": "Macro evaluates parameter 'ts' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 432, "message": "Function-like macro 'getstr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 432, "message": "Macro evaluates parameter 'ts' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 436, "message": "Function-like macro 'tsslen' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 436, "message": "Macro evaluates parameter 'ts' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 441, "message": "Function-like macro 'getlstr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 441, "message": "Macro evaluates parameter 'ts' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 467, "message": "Function-like macro 'pvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 467, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 468, "message": "Function-like macro 'uvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 468, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 472, "message": "Multistatement macro 'setpvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 475, "message": "Multistatement macro 'setuvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 498, "message": "Flexible array member should use [] not [1]", "rule_id": "DCL38-C", "severity": "Medium", "suggestion": "Use int data[]; syntax"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 498, "message": "Character array too small to hold any string data plus null terminator", "rule_id": "STR31-C", "severity": "Medium", "suggestion": "Increase array size to accommodate expected string length plus null terminator"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 521, "message": "Function-like macro 'udatamemoffset' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 521, "message": "Macro evaluates parameter 'nuv' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 526, "message": "Function-like macro 'getudatamem' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 526, "message": "Macro evaluates parameter 'u' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 649, "message": "Function-like macro 'ttisclosure' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 649, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 654, "message": "Function-like macro 'clvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 654, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 655, "message": "Function-like macro 'clLvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 655, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 656, "message": "Function-like macro 'fvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 656, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 657, "message": "Function-like macro 'clCvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 657, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 661, "message": "Multistatement macro 'setclLvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 668, "message": "Multistatement macro 'setfvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 671, "message": "Multistatement macro 'setclCvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 697, "message": "Multistatement macro 'ClosureHeader' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 703, "message": "Flexible array member should use [] not [1]", "rule_id": "DCL38-C", "severity": "Medium", "suggestion": "Use int data[]; syntax"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 703, "message": "Character array too small to hold any string data plus null terminator", "rule_id": "STR31-C", "severity": "Medium", "suggestion": "Increase array size to accommodate expected string length plus null terminator"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 710, "message": "Flexible array member should use [] not [1]", "rule_id": "DCL38-C", "severity": "Medium", "suggestion": "Use int data[]; syntax"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 710, "message": "Character array too small to hold any string data plus null terminator", "rule_id": "STR31-C", "severity": "Medium", "suggestion": "Increase array size to accommodate expected string length plus null terminator"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 735, "message": "Function-like macro 'hvalue' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 735, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 737, "message": "Multistatement macro 'sethvalue' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 764, "message": "Multistatement macro 'setnodekey' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 770, "message": "Multistatement macro 'getnodekey' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 806, "message": "Function-like macro 'gckeyN' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 806, "message": "Macro evaluates parameter 'n' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 825, "message": "Function-like macro 'lmod' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 825, "message": "Macro parameter 'size' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'size' in parentheses: (size) instead of size"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 825, "message": "Macro evaluates parameter 'size' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 838, "message": "Macro 'LUAI_FUNC' definition ends with a semicolon. This can cause unexpected behavior when the macro is used.", "rule_id": "PRE11-C", "severity": "Medium", "suggestion": "Remove the trailing semicolon from the macro definition. The semicolon should be added by the macro user, not in the definition."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 855, "message": "Function has pointer parameter without size argument: 'LUAI_FUNC unsigned luaO_tostringbuff (const TValue *obj, char *buff);' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'char *buff' to specify the maximum number of elements in the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 860, "message": "Variadic function declaration should use proper header", "rule_id": "EXP37-C", "severity": "Medium", "suggestion": "Include proper header instead of declaring variadic function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 861, "message": "Function has pointer parameter without size argument: 'LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t srclen);' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'char *out' to specify the maximum number of elements in the array"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 861, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lobject.h", "line": 861, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.c", "line": 22, "message": "Variable 'luaP_opmodes' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.c", "line": 22, "message": "File-scope variable should have minimal scope. Consider making it static within a function or limiting its scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Move variable to the smallest scope where it's used, or make it static inside a function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.c", "line": 112, "message": "Macro parameter 'm' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'm' in parentheses: (m) instead of m"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 128, "message": "Function-like macro 'SET_OPCODE' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 128, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 135, "message": "Function-like macro 'setarg' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 135, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 141, "message": "Function-like macro 'GETARG_B' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 141, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 143, "message": "Function-like macro 'GETARG_vB' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 143, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 149, "message": "Function-like macro 'GETARG_C' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 149, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 151, "message": "Function-like macro 'GETARG_vC' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 151, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 161, "message": "Function-like macro 'GETARG_Bx' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 161, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 164, "message": "Function-like macro 'GETARG_Ax' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 164, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 167, "message": "Function-like macro 'GETARG_sBx' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 167, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp(checkopm(i, iAsBx), getarg(i, POS_Bx, SIZE_Bx) - OFFSET_sBx))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 167, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 171, "message": "Function-like macro 'GETARG_sJ' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 171, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp(checkopm(i, isJ), getarg(i, POS_sJ, SIZE_sJ) - OFFSET_sJ))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 171, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 425, "message": "Declaration is missing an explicit type specifier", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Add an explicit type specifier to the declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 427, "message": "Macro parameter 'm' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'm' in parentheses: (m) instead of m"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 428, "message": "Macro parameter 'm' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'm' in parentheses: (m) instead of m"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 429, "message": "Macro parameter 'm' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'm' in parentheses: (m) instead of m"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 430, "message": "Macro parameter 'm' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'm' in parentheses: (m) instead of m"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 436, "message": "Function-like macro 'luaP_isOT' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopcodes.h", "line": 436, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lopnames.h", "line": 1, "message": "Header file missing include guard", "rule_id": "PRE06-C", "severity": "Low", "suggestion": "Add #ifndef HEADER_H / #define HEADER_H / #endif guard"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lopnames.h", "line": 15, "message": "Array declaration 'opnames[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 115, "message": "Function-like macro 'lua_tmpnam' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 115, "message": "Macro parameter 'e' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'e' in parentheses: (e) instead of e"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 115, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ \\\n strcpy(b, LUA_TMPNAMTEMPLATE); \\\n e = mkstemp(b); \\\n if (e != -1) close(e); \\\n e = (e == -1); })"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 115, "message": "Multistatement macro 'lua_tmpnam' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 115, "message": "Macro evaluates parameter 'b' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 125, "message": "Macro parameter 'e' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'e' in parentheses: (e) instead of e"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 125, "message": "Multistatement macro 'lua_tmpnam' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 29, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 168, "message": "rename() called without handling destination file existence. Behavior is implementation-defined (POSIX removes dest, Windows fails).", "rule_id": "FIO10-C", "severity": "Medium", "suggestion": "Either: (1) Call remove(dest) before rename(), OR (2) Check if dest exists with file_exists()/access()/stat() and handle accordingly"}, {"column": 21, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 184, "message": "'getenv()' uses internal static storage that is shared between threads", "rule_id": "CON34-C", "severity": "Medium", "suggestion": "Use 'secure_getenv or a cached copy' instead for thread safety"}, {"column": 51, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 233, "message": "Pointer parameter 'stm' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *stm'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 234, "message": "Passing string literal to function 'setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 235, "message": "Passing string literal to function 'setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 236, "message": "Passing string literal to function 'setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 237, "message": "Passing string literal to function 'setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 238, "message": "Passing string literal to function 'setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 239, "message": "Passing string literal to function 'setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 240, "message": "Passing string literal to function 'setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 241, "message": "Passing string literal to function 'setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 242, "message": "Passing string literal to function 'setboolfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 31, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 256, "message": "'key' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 8, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 258, "message": "Variable 'isnum' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'isnum' before use, e.g., at its declaration"}, {"column": 58, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 275, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 54, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 276, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 7, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 283, "message": "memcpy used for string copying may not include null terminator", "rule_id": "STR31-C", "severity": "Medium", "suggestion": "Use strcpy/strncpy or memcpy with size+1 for null terminator"}, {"column": 24, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 309, "message": "Variable 'slen' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'slen' before use, e.g., at its declaration"}, {"column": 7, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 311, "message": "Potential null pointer dereference of variable 's'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before dereferencing"}, {"column": 9, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 338, "message": "Return value of 'strftime' assigned to 'reslen' but not checked for errors: 'strftime(buff, SIZETIMEFMT, cc, stm)' - Can return error indicator", "rule_id": "ERR33-C", "severity": "High", "suggestion": "Check return value for errors"}, {"column": 5, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 363, "message": "Return value of 'mktime' assigned to 't' but not checked for errors: 'mktime(&ts)' - Can return error indicator", "rule_id": "ERR33-C", "severity": "High", "suggestion": "Check return value for errors"}, {"column": 20, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 385, "message": "Array declaration 'cat[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 28, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 387, "message": "Array declaration 'catnames[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 42, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 390, "message": "'catnames' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 21, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 391, "message": "Call to non-thread-safe function 'setlocale'. Protect multithreaded access to locale-specific functions with a mutex", "rule_id": "CON33-C", "severity": "Medium", "suggestion": "Protect multithreaded access to locale-specific functions with a mutex"}, {"column": 21, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 391, "message": "'setlocale()' uses internal static storage that is shared between threads", "rule_id": "CON34-C", "severity": "Medium", "suggestion": "Use 'uselocale' instead for thread safety"}, {"column": 10, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 404, "message": "Function 'os_exit' calls 'exit', which dictates error handling. Application-independent code should report errors to the caller (via return values, error parameters, or error indicators) rather than terminating the program.", "rule_id": "ERR05-C", "severity": "Medium", "suggestion": "Replace 'exit' with error reporting via return value (e.g., 'return ERROR_CODE;'), error parameter (e.g., '*err = ERROR_CODE;'), or global error indicator"}, {"column": 23, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 409, "message": "Array declaration 'syslib[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 428, "message": "Function 'luaopen_os' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/loslib.c", "line": 428, "message": "Function 'luaopen_os' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_os"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 38, "message": "Function-like macro 'hasmultret' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 38, "message": "Macro evaluates parameter 'k' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 68, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 74, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 74, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 122, "message": "Multistatement macro 'check_condition' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 28, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 135, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 148, "message": "Function returns pointer to local variable 'ts' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 159, "message": "Pointer parameter 's' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *s'"}, {"column": 41, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 175, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 194, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 194, "message": "Pointer parameter 'name' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *name'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 199, "message": "Function 'luaM_growvector' called with overlapping memory regions. If parameters are restrict-qualified, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure memory regions do not overlap when using restrict pointers"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 215, "message": "Function-like macro 'new_localvarliteral' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 215, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (new_localvar(ls, \\\n luaX_newstring(ls, \"\" v, (sizeof(v)/sizeof(char)) - 1));)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 215, "message": "Macro 'new_localvarliteral' definition ends with a semicolon. This can cause unexpected behavior when the macro is used.", "rule_id": "PRE11-C", "severity": "Medium", "suggestion": "Remove the trailing semicolon from the macro definition. The semicolon should be added by the macro user, not in the definition."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 215, "message": "Macro evaluates parameter 'ls' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 44, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 226, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 250, "message": "Function 'luaY_nvarstack' does not validate pointer parameter 'fs' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'fs' at the start of the function, e.g., 'if (!fs) { return error_code; }'"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 360, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 373, "message": "Function 'luaY_checklimit' called with overlapping memory regions. If parameters are restrict-qualified, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure memory regions do not overlap when using restrict pointers"}, {"column": 62, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 382, "message": "Pointer parameter 'v' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *v'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 476, "message": "Recursive function can cause excessive stack allocation", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Consider iterative approach or limit recursion depth"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 476, "message": "Function 'singlevaraux' calls itself directly (direct recursion)", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to use iteration instead of recursion"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 547, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 570, "message": "Macro parameter 'ls' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'ls' in parentheses: (ls) instead of ls"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 573, "message": "Function-like macro 'leavelevel' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 580, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 56, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 580, "message": "Pointer parameter 'gt' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *gt'"}, {"column": 55, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 597, "message": "Pointer parameter 'label' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *label'"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 601, "message": "Array subscript uses function parameter 'g' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'g' before using it as an array index"}, {"column": 27, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 611, "message": "Memory allocated with 'CREATE_ABCk' for variable 'fs->f->code[gt->pc]' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(fs->f->code[gt->pc])' before the variable goes out of scope"}, {"column": 39, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 626, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 628, "message": "Loop uses uninitialized variable 'ilb' as bound for array access. This has indeterminate value and can cause out-of-bounds access.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Initialize 'ilb' to a valid value before using it in the loop"}, {"column": 36, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 640, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 63, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 640, "message": "Pointer parameter 'name' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *name'"}, {"column": 49, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 696, "message": "Pointer parameter 'bl' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *bl'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 737, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 51, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 737, "message": "Pointer parameter 'gt' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *gt'"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 768, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 781, "message": "Function returns pointer to local variable 'clp' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 792, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 823, "message": "Memory allocated with 'luaH_new' for variable 'fs->kcache' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(fs->kcache)' before the variable goes out of scope"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 866, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 877, "message": "Function 'statlist' participates in indirect recursion: statlist -> statement -> localstat -> explist -> expr -> subexpr -> simpleexp -> body -> statlist", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 900, "message": "Function 'yindex' participates in indirect recursion: yindex -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field -> recfield -> yindex", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 938, "message": "Function 'recfield' participates in indirect recursion: recfield -> yindex -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field -> recfield", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 985, "message": "Function 'listfield' participates in indirect recursion: listfield -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field -> listfield", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 992, "message": "Function 'field' participates in indirect recursion: field -> recfield -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1019, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1019, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1030, "message": "Function 'constructor' participates in indirect recursion: constructor -> field -> listfield -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1105, "message": "Function 'body' participates in indirect recursion: body -> statlist -> statement -> localstat -> explist -> expr -> subexpr -> simpleexp -> body", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1127, "message": "Function 'explist' participates in indirect recursion: explist -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> explist", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1140, "message": "Function 'funcargs' participates in indirect recursion: funcargs -> explist -> expr -> subexpr -> simpleexp -> suffixedexp -> funcargs", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1152, "message": "Variable 'args' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'args' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1198, "message": "Function 'primaryexp' participates in indirect recursion: primaryexp -> expr -> subexpr -> simpleexp -> suffixedexp -> primaryexp", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1220, "message": "Function 'suffixedexp' participates in indirect recursion: suffixedexp -> yindex -> expr -> subexpr -> simpleexp -> suffixedexp", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1257, "message": "Function 'simpleexp' participates in indirect recursion: simpleexp -> constructor -> field -> listfield -> expr -> subexpr -> simpleexp", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1357, "message": "Array declaration 'priority[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1377, "message": "Recursive function can cause excessive stack allocation", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Consider iterative approach or limit recursion depth"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1377, "message": "Function 'subexpr' calls itself directly (direct recursion)", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to use iteration instead of recursion"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1407, "message": "Function 'expr' participates in indirect recursion: expr -> subexpr -> simpleexp -> suffixedexp -> funcargs -> constructor -> field -> listfield -> expr", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1422, "message": "Function 'block' participates in indirect recursion: block -> statlist -> statement -> ifstat -> block", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1448, "message": "Pointer parameter 'ls' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ls'"}, {"column": 74, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1448, "message": "Pointer parameter 'v' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *v'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1501, "message": "Recursive function can cause excessive stack allocation", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Consider iterative approach or limit recursion depth"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1501, "message": "Function 'restassign' calls itself directly (direct recursion)", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to use iteration instead of recursion"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1531, "message": "Function 'cond' participates in indirect recursion: cond -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> repeatstat -> cond", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1558, "message": "Potential null pointer dereference in member access of variable 'bl'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'bl' is not NULL before member access"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1572, "message": "Potential null pointer dereference in member access of variable 'lb'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'lb' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1576, "message": "Function 'labelstat' participates in indirect recursion: labelstat -> statement -> labelstat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1586, "message": "Function 'whilestat' participates in indirect recursion: whilestat -> block -> statlist -> statement -> whilestat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1605, "message": "Function 'repeatstat' participates in indirect recursion: repeatstat -> cond -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> repeatstat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1635, "message": "Function 'exp1' participates in indirect recursion: exp1 -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> forstat -> fornum -> exp1", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1648, "message": "Pointer parameter 'fs' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *fs'"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1649, "message": "Array subscript uses function parameter 'pc' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'pc' before using it as an array index"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1649, "message": "Potentially unsafe array access with unvalidated function parameter index 'pc'", "rule_id": "ARR30-C", "severity": "High", "suggestion": "Add bounds checking for function parameter before using as array index."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1662, "message": "Function 'forbody' participates in indirect recursion: forbody -> block -> statlist -> statement -> forstat -> forlist -> forbody", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 27, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1670, "message": "Array subscript uses function parameter 'isgen' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'isgen' before using it as an array index"}, {"column": 29, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1682, "message": "Array subscript uses function parameter 'isgen' without bounds checking. Caller could pass invalid index.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Add bounds checking for 'isgen' before using it as an array index"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1697, "message": "Function 'fornum' participates in indirect recursion: fornum -> forbody -> block -> statlist -> statement -> forstat -> fornum", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1719, "message": "Function 'forlist' participates in indirect recursion: forlist -> forbody -> block -> statlist -> statement -> forstat -> forlist", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1746, "message": "Function 'forstat' participates in indirect recursion: forstat -> forlist -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> forstat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1764, "message": "Function 'test_then_block' participates in indirect recursion: test_then_block -> cond -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> ifstat -> test_then_block", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1779, "message": "Function 'ifstat' participates in indirect recursion: ifstat -> test_then_block -> block -> statlist -> statement -> ifstat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1793, "message": "Function 'localfunc' participates in indirect recursion: localfunc -> body -> statlist -> statement -> localfunc", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1830, "message": "Function 'localstat' participates in indirect recursion: localstat -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> localstat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1844, "message": "Memory allocated with 'new_varkind' for variable 'vidx' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(vidx)' before the variable goes out of scope"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1906, "message": "Recursive function can cause excessive stack allocation", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Consider iterative approach or limit recursion depth"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1906, "message": "Function 'initglobal' calls itself directly (direct recursion)", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to use iteration instead of recursion"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1927, "message": "Function 'globalnames' participates in indirect recursion: globalnames -> initglobal -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> globalstatfunc -> globalstat -> globalnames", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1934, "message": "Memory allocated with 'new_varkind' for variable 'lastidx' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(lastidx)' before the variable goes out of scope"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1943, "message": "Function 'globalstat' participates in indirect recursion: globalstat -> globalnames -> initglobal -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> globalstatfunc -> globalstat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1959, "message": "Function 'globalfunc' participates in indirect recursion: globalfunc -> body -> statlist -> statement -> globalstatfunc -> globalfunc", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1974, "message": "Function 'globalstatfunc' participates in indirect recursion: globalstatfunc -> globalfunc -> body -> statlist -> statement -> globalstatfunc", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 1998, "message": "Function 'funcstat' participates in indirect recursion: funcstat -> body -> statlist -> statement -> funcstat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2011, "message": "Function 'exprstat' participates in indirect recursion: exprstat -> restassign -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> exprstat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2015, "message": "Variable 'v' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'v' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2029, "message": "Function 'retstat' participates in indirect recursion: retstat -> explist -> expr -> subexpr -> simpleexp -> body -> statlist -> statement -> retstat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2061, "message": "Function 'statement' participates in indirect recursion: statement -> block -> statlist -> statement", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2180, "message": "Function 'luaY_parser' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2180, "message": "Function 'luaY_parser' does not validate pointer parameter 'z' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'z' at the start of the function, e.g., 'if (!z) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2180, "message": "Function 'luaY_parser' does not validate pointer parameter 'anchor' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'anchor' at the start of the function, e.g., 'if (!anchor) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2180, "message": "Function 'luaY_parser' does not validate pointer parameter 'buff' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'buff' at the start of the function, e.g., 'if (!buff) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2180, "message": "Function 'luaY_parser' does not validate pointer parameter 'dyd' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'dyd' at the start of the function, e.g., 'if (!dyd) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2180, "message": "Function 'luaY_parser' does not validate pointer parameter 'name' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'name' at the start of the function, e.g., 'if (!name) { return error_code; }'"}, {"column": 69, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2180, "message": "Pointer parameter 'buff' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *buff'"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2188, "message": "Potential null pointer dereference in member access of variable 'cl'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'cl' is not NULL before member access"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2190, "message": "Memory allocated with 'luaS_new' for variable 'funcstate.f->source' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(funcstate.f->source)' before the variable goes out of scope"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2200, "message": "Function returns pointer to local variable 'cl' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lparser.c", "line": 2200, "message": "Memory leak: 'funcstate.f->source' allocated with 'luaS_new' is not freed before return", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Free 'funcstate.f->source' before this return statement"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.h", "line": 74, "message": "Function-like macro 'vkisvar' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.h", "line": 74, "message": "Macro evaluates parameter 'k' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.h", "line": 75, "message": "Function-like macro 'vkisindexed' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lparser.h", "line": 75, "message": "Macro evaluates parameter 'k' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lprefix.h", "line": 17, "message": "Reserved identifier '_XOPEN_SOURCE' should not be used as a macro name", "rule_id": "DCL37-C", "severity": "Medium", "suggestion": "Use a non-reserved macro name"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lprefix.h", "line": 26, "message": "Reserved identifier '_LARGEFILE_SOURCE' should not be used as a macro name", "rule_id": "DCL37-C", "severity": "Medium", "suggestion": "Use a non-reserved macro name"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lprefix.h", "line": 27, "message": "Reserved identifier '_FILE_OFFSET_BITS' should not be used as a macro name", "rule_id": "DCL37-C", "severity": "Medium", "suggestion": "Use a non-reserved macro name"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lprefix.h", "line": 39, "message": "Reserved identifier '_CRT_SECURE_NO_WARNINGS' should not be used as a macro name", "rule_id": "DCL37-C", "severity": "Medium", "suggestion": "Use a non-reserved macro name"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 61, "message": "Function 'luaE_setdebt' does not validate pointer parameter 'g' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'g' at the start of the function, e.g., 'if (!g) { return error_code; }'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 76, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 79, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 79, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 18, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 80, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 81, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 82, "message": "Use-after-free: accessing member of freed pointer 'ci'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 85, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 86, "message": "Function returns pointer to local variable 'ci' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 115, "message": "Potential null pointer dereference in member access of variable 'next'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'next' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 136, "message": "Function 'luaE_checkcstack' participates in indirect recursion: luaE_checkcstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaE_checkcstack", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 144, "message": "Function 'luaE_incCstack' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 182, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 21, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 184, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 44, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 184, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 21, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 194, "message": "Memory allocated with 'luaH_new' for variable 'registry' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(registry)' before the variable goes out of scope"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 201, "message": "Function 'setthvalue' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 213, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 215, "message": "Function 'stack_init' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 56, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 230, "message": "Pointer parameter 'g' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *g'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 251, "message": "Function 'luaE_threadsize' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 261, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 269, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 21, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 271, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 49, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 271, "message": "Use-after-free: passing freed pointer 'L' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 272, "message": "Double-free: 'L' freed multiple times", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Set pointer to NULL after freeing to prevent double-free."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 278, "message": "Function 'lua_newthread' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 279, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 296, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 301, "message": "Function returns pointer to local variable 'L1' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 310, "message": "Double-free: 'L1' freed multiple times", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Set pointer to NULL after freeing to prevent double-free."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 315, "message": "Function 'luaE_resetthread' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 321, "message": "Function 'luaD_seterrorobj' called with overlapping memory regions. If parameters are restrict-qualified, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure memory regions do not overlap when using restrict pointers"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 324, "message": "Use-after-free: pointer arithmetic on freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not use freed pointers in arithmetic."}, {"column": 33, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 324, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 33, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 324, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 33, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 324, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 48, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 324, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 48, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 324, "message": "Use-after-free: accessing member of freed pointer 'L'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 329, "message": "Function 'lua_closethread' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 329, "message": "Function 'lua_closethread' does not validate pointer parameter 'from' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'from' at the start of the function, e.g., 'if (!from) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 329, "message": "Function 'lua_closethread' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_closethread"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 341, "message": "Function 'lua_newstate' does not validate pointer parameter 'ud' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ud' at the start of the function, e.g., 'if (!ud) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 344, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 16, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 344, "message": "Function pointer stored without encryption; consider using EncodePointer()", "rule_id": "WIN04-C", "severity": "High", "suggestion": "Use EncodePointer() to encrypt the function pointer before storage"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 392, "message": "Function returns pointer to local variable 'L' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 396, "message": "Function 'lua_close' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 396, "message": "Function 'lua_close' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUA_API lua_close"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 403, "message": "Function 'luaE_warning' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 406, "message": "Function 'wf' is called without prior declaration", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Declare the function before calling it or include the appropriate header"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 413, "message": "Function 'luaE_warnerror' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.c", "line": 413, "message": "Function 'luaE_warnerror' does not validate pointer parameter 'where' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'where' at the start of the function, e.g., 'if (!where) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 158, "message": "Function-like macro 'stacksize' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 158, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast_int((th)->stack_last.p - (th)->stack.p))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 158, "message": "Macro evaluates parameter 'th' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 263, "message": "Function-like macro 'setcistrecst' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 263, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp(((st) & 7) == (st),)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 263, "message": "Macro evaluates parameter 'st' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 36, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 266, "message": "Unsigned integer left shift 'cast(l_uint32, st) << CIST_RECST' may cause overflow without checking", "rule_id": "INT30-C", "severity": "High", "suggestion": "Add shift overflow check before shifting"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 276, "message": "Function-like macro 'setoah' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 276, "message": "Macro evaluates parameter 'ci' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 375, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 382, "message": "Macro parameter 'g' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'g' in parentheses: (g) instead of g"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 414, "message": "Function-like macro 'gco2ts' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 414, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 414, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 416, "message": "Function-like macro 'gco2u' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 416, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp((o)->tt == LUA_VUSERDATA, &((cast_u(o))->u)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 416, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 417, "message": "Function-like macro 'gco2lcl' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 417, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp((o)->tt == LUA_VLCL, &((cast_u(o))->cl.l)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 417, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 418, "message": "Function-like macro 'gco2ccl' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 418, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp((o)->tt == LUA_VCCL, &((cast_u(o))->cl.c)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 418, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 419, "message": "Function-like macro 'gco2cl' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 419, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 419, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 421, "message": "Function-like macro 'gco2t' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 421, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp((o)->tt == LUA_VTABLE, &((cast_u(o))->h)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 421, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 422, "message": "Function-like macro 'gco2p' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 422, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp((o)->tt == LUA_VPROTO, &((cast_u(o))->p)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 422, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 423, "message": "Function-like macro 'gco2th' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 423, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp((o)->tt == LUA_VTHREAD, &((cast_u(o))->th)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 423, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 424, "message": "Function-like macro 'gco2upv' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 424, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp((o)->tt == LUA_VUPVAL, &((cast_u(o))->upv)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 424, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 430, "message": "Function-like macro 'obj2gco' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 430, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp(novariant((v)->tt) >= LUA_TSTRING, &(cast_u(v)->gc)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 430, "message": "Macro evaluates parameter 'v' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 435, "message": "Function-like macro 'gettotalbytes' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstate.h", "line": 435, "message": "Macro evaluates parameter 'g' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 44, "message": "Function 'luaS_eqstr' does not validate pointer parameter 'a' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'a' at the start of the function, e.g., 'if (!a) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 44, "message": "Function 'luaS_eqstr' does not validate pointer parameter 'b' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'b' at the start of the function, e.g., 'if (!b) { return error_code; }'"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 48, "message": "Variable 'len1' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len1' before use, e.g., at its declaration"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 48, "message": "Variable 'len2' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len2' before use, e.g., at its declaration"}, {"column": 39, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 53, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 54, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 20, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 54, "message": "Variable 'l' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 56, "message": "Variable 'h' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 56, "message": "Input operation on file stream 'h' follows output without intervening positioning call (fflush, fseek, fsetpos, or rewind)", "rule_id": "FIO50-C", "severity": "Low", "suggestion": "Insert fflush() or a positioning function (fseek, fsetpos, rewind) between output and input operations"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 56, "message": "Input operation on file stream 'h' follows output without intervening positioning call (fflush, fseek, fsetpos, or rewind)", "rule_id": "FIO50-C", "severity": "Low", "suggestion": "Insert fflush() or a positioning function (fseek, fsetpos, rewind) between output and input operations"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 61, "message": "Function 'luaS_hashlongstr' does not validate pointer parameter 'ts' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ts' at the start of the function, e.g., 'if (!ts) { return error_code; }'"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 81, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 95, "message": "Function 'luaS_resize' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 120, "message": "Function 'luaS_clearcache' does not validate pointer parameter 'g' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'g' at the start of the function, e.g., 'if (!g) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 133, "message": "Function 'luaS_init' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 134, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 149, "message": "Function 'luaS_sizelngstr' does not validate integer parameter 'len' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'len' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 175, "message": "Function returns pointer to local variable 'ts' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 179, "message": "Function 'luaS_createlngstrobj' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 182, "message": "Potential null pointer dereference in member access of variable 'ts'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'ts' is not NULL before member access"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 184, "message": "Pointer arithmetic on struct pointer with byte offset. Cast to char* before adding offset.", "rule_id": "EXP08-C", "severity": "Medium", "suggestion": null}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 186, "message": "Function returns pointer to local variable 'ts' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 190, "message": "Function 'luaS_remove' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 190, "message": "Function 'luaS_remove' does not validate pointer parameter 'ts' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ts' at the start of the function, e.g., 'if (!ts) { return error_code; }'"}, {"column": 41, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 190, "message": "Pointer parameter 'ts' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ts'"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 192, "message": "Pointer-to-pointer assignment may allow const circumvention: **p = &tb->hash[lmod(ts->hash, tb->size)]: '**p = &tb->hash[lmod(ts->hash, tb->size)]'", "rule_id": "EXP40-C", "severity": "Low", "suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 200, "message": "Function 'growstrtab' participates in indirect recursion: growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 51, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 200, "message": "Pointer parameter 'tb' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *tb'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 214, "message": "Function 'internshrstr' participates in indirect recursion: internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 56, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 214, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 216, "message": "Variable 'g' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const g = ..."}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 218, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 218, "message": "'str' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 219, "message": "Pointer-to-pointer assignment may allow const circumvention: **list = &tb->hash[lmod(h, tb->size)]: '**list = &tb->hash[lmod(h, tb->size)]'", "rule_id": "EXP40-C", "severity": "Low", "suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 223, "message": "Function 'memcmp' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 227, "message": "Function returns pointer to local variable 'ts' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 236, "message": "Potential null pointer dereference in member access of variable 'ts'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'ts' is not NULL before member access"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 238, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 240, "message": "Local variable 'ts' assigned through pointer parameter - address will be invalid when function returns", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Copy data instead of assigning pointer, or use static/allocated storage"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 242, "message": "Function returns pointer to local variable 'ts' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 249, "message": "Function 'luaS_newlstr' participates in indirect recursion: luaS_newlstr -> luaM_toobig -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 49, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 249, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 257, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 257, "message": "memcpy called with potentially overlapping memory regions (both derive from 'getlngstr(ts)'). memcpy's restrict parameters require non-overlapping memory.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Use memmove for overlapping memory regions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 269, "message": "Function 'luaS_new' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 269, "message": "Function 'luaS_new' does not validate pointer parameter 'str' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'str' at the start of the function, e.g., 'if (!str) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 269, "message": "Function 'luaS_new' participates in indirect recursion: luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 31, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 270, "message": "'str' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 36, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 270, "message": "Modulo operator used with potentially signed operands. The result of % with negative operands is implementation-defined and can be negative. Use unsigned types (size_t, unsigned int) or explicitly handle negative remainders.", "rule_id": "INT10-C", "severity": "Medium", "suggestion": "Convert operands to unsigned types (size_t, unsigned int) or add explicit checks for negative values"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 286, "message": "Function 'luaS_newudata' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 299, "message": "Function returns pointer to local variable 'u' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 42, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 311, "message": "Pointer parameter 'ud' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ud'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 318, "message": "Function 'luaS_newextlstr' does not validate pointer parameter 's' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 's' at the start of the function, e.g., 'if (!s) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 318, "message": "Function 'luaS_newextlstr' does not validate integer parameter 'len' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'len' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 319, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 62, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 319, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 344, "message": "Function 'luaS_normstr' does not validate pointer parameter 'ts' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ts' at the start of the function, e.g., 'if (!ts) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.c", "line": 344, "message": "Function 'luaS_normstr' participates in indirect recursion: luaS_normstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_set -> luaH_finishset -> luaS_normstr", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 41, "message": "Function-like macro 'luaS_newliteral' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 41, "message": "Macro evaluates parameter 's' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 48, "message": "Function-like macro 'isreserved' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 48, "message": "Macro evaluates parameter 's' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 54, "message": "Function-like macro 'eqshrstr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 54, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 54, "message": "Macro evaluates parameter 'a' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 59, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 65, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 69, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lstring.h", "line": 69, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 88, "message": "Variable 'l' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 101, "message": "Variable 'l' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 103, "message": "Potential null pointer dereference in array access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before array access"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 103, "message": "Potential null pointer dereference in array access of variable 's'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before array access"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 114, "message": "Variable 'l' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 116, "message": "Potential null pointer dereference in array access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before array access"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 116, "message": "Argument to 'tolower()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'tolower((unsigned char)...)'"}, {"column": 41, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 116, "message": "Potential null pointer dereference in array access of variable 's'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before array access"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 127, "message": "Variable 'l' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 129, "message": "Potential null pointer dereference in array access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before array access"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 129, "message": "Argument to 'toupper()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'toupper((unsigned char)...)'"}, {"column": 41, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 129, "message": "Potential null pointer dereference in array access of variable 's'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before array access"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 144, "message": "Variable 'len' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len' before use, e.g., at its declaration"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 144, "message": "Variable 'len' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 144, "message": "Variable 'lsep' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 144, "message": "Variable 'lsep' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'lsep' before use, e.g., at its declaration"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 154, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 154, "message": "Do not cast away const qualification: 'p'", "rule_id": "EXP05-C", "severity": "Medium", "suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 154, "message": "Passing potentially null pointer 'p' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before passing to function"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 154, "message": "Passing potentially null pointer 's' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before passing to function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 156, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 156, "message": "Do not cast away const qualification: 'p'", "rule_id": "EXP05-C", "severity": "Medium", "suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 156, "message": "Passing potentially null pointer 'sep' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'sep' is not NULL before passing to function"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 159, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 159, "message": "Do not cast away const qualification: 'p'", "rule_id": "EXP05-C", "severity": "Medium", "suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 169, "message": "Variable 'pi' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const pi = ..."}, {"column": 31, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 170, "message": "Variable 'l' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 176, "message": "Unsigned subtraction 'pose - posi' without guard assumes non-negative result", "rule_id": "INT00-C", "severity": "Medium", "suggestion": "Add a guard: if (a >= b) before unsigned subtraction a - b"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 179, "message": "Potential null pointer dereference in array access of variable 's'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before array access"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 190, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 192, "message": "Potential null pointer dereference in array access of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before array access"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 192, "message": "Signed integer subtraction 'i - 1' may overflow without proper checking", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add overflow check: if ((b < 0 && a > INT_MAX + b) || (b > 0 && a < INT_MIN + b)) { /* handle error */ }"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 211, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 67, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 211, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 6, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 217, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 252, "message": "Array declaration 'stringmetamethods[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 54, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 267, "message": "Variable 'len' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 283, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 294, "message": "Function 'trymt' called with overlapping memory regions. If parameters are restrict-qualified, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure memory regions do not overlap when using restrict pointers"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 332, "message": "Array declaration 'stringmetamethods[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 388, "message": "Pointer parameter 'ms' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ms'"}, {"column": 41, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 397, "message": "Pointer parameter 'ms' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ms'"}, {"column": 41, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 405, "message": "Pointer parameter 'ms' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ms'"}, {"column": 2, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 406, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 417, "message": "Variable(s) 'p' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 431, "message": "Argument to 'tolower()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'tolower((unsigned char)...)'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 432, "message": "Argument to 'isalpha()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isalpha((unsigned char)...)'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 433, "message": "Argument to 'iscntrl()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'iscntrl((unsigned char)...)'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 434, "message": "Argument to 'isdigit()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isdigit((unsigned char)...)'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 435, "message": "Argument to 'isgraph()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isgraph((unsigned char)...)'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 436, "message": "Argument to 'islower()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'islower((unsigned char)...)'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 437, "message": "Argument to 'ispunct()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'ispunct((unsigned char)...)'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 438, "message": "Argument to 'isspace()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isspace((unsigned char)...)'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 439, "message": "Argument to 'isupper()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isupper((unsigned char)...)'"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 440, "message": "Argument to 'isalnum()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isalnum((unsigned char)...)'"}, {"column": 31, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 441, "message": "Argument to 'isxdigit()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isxdigit((unsigned char)...)'"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 445, "message": "Argument to 'islower()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'islower((unsigned char)...)'"}, {"column": 36, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 472, "message": "Pointer parameter 'ms' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ms'"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 477, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 24, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 477, "message": "Pointer dereference '*s' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 477, "message": "Pointer dereference '*s' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 477, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 477, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 4, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 478, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 488, "message": "Pointer parameter 'ms' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ms'"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 494, "message": "Pointer dereference '*p' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 494, "message": "Pointer dereference '*p' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 494, "message": "Pointer dereference '*p' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 494, "message": "Pointer dereference '*p' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 494, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 494, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 495, "message": "Variable 'e' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const e = ..."}, {"column": 15, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 495, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 495, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 508, "message": "Function 'max_expand' participates in indirect recursion: max_expand -> match -> max_expand", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 515, "message": "Static variable 'match' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'match' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 523, "message": "Function 'min_expand' participates in indirect recursion: min_expand -> match -> min_expand", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 523, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 526, "message": "Static variable 'match' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'match' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 536, "message": "Function 'start_capture' participates in indirect recursion: start_capture -> match -> start_capture", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 544, "message": "Static variable 'match' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'match' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 546, "message": "Function returns pointer to local variable 'res' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 550, "message": "Function 'end_capture' participates in indirect recursion: end_capture -> match -> end_capture", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 555, "message": "Static variable 'match' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'match' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 557, "message": "Function returns pointer to local variable 'res' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 572, "message": "Function 'match' calls itself directly (direct recursion)", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to use iteration instead of recursion"}, {"column": 4, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 577, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 8, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 596, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 642, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 645, "message": "Static variable 'match' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'match' before use, e.g., at its declaration"}, {"column": 41, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 675, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 43, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 676, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 685, "message": "Passing potentially null pointer 'init' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'init' is not NULL before passing to function"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 704, "message": "Pointer parameter 'ms' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ms'"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 709, "message": "Pointer dereference '*cap' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 710, "message": "Pointer subtraction between pointers from different arrays: 'param:e' and 'param:s'", "rule_id": "ARR36-C", "severity": "High", "suggestion": "Ensure both pointers refer to the same array before subtraction"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 714, "message": "Pointer dereference '*cap' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 39, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 731, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 39, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 731, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 42, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 731, "message": "'e' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 731, "message": "Pointer dereference '*cap' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 46, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 731, "message": "'cap' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 28, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 733, "message": "Variable 'cap' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'cap' before use, e.g., at its declaration"}, {"column": 36, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 740, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 36, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 740, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 749, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 50, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 763, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 764, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 61, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 764, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 786, "message": "Variable 'ls' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ls' before use, e.g., at its declaration"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 792, "message": "Variable 'lp' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'lp' before use, e.g., at its declaration"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 804, "message": "Potential null pointer dereference of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before dereferencing"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 804, "message": "Pointer dereference '*p' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 804, "message": "Pointer dereference '*p' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 804, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 804, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 812, "message": "Static variable 'match' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'match' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 850, "message": "Potential null pointer dereference in member access of variable 'gm'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'gm' is not NULL before member access"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 854, "message": "Variable(s) 'e' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 854, "message": "Static variable 'match' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'match' before use, e.g., at its declaration"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 854, "message": "Variable 'e' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'e' before use, e.g., at its declaration"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 867, "message": "Variable 'ls' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ls' before use, e.g., at its declaration"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 873, "message": "Potential null pointer dereference in member access of variable 'gm'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'gm' is not NULL before member access"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 873, "message": "Variable 'lp' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'lp' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 886, "message": "Unbounded while loop with pointer increment. Loop increments 'p' without size/length bounds checking.", "rule_id": "ARR30-C", "severity": "High", "suggestion": "Add bounds checking to while condition (e.g., counter < max_size)"}, {"column": 43, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 886, "message": "Variable 'l' may be used uninitialized (not assigned on all paths)", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 889, "message": "Potential null pointer dereference of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before dereferencing"}, {"column": 42, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 892, "message": "Pointer subtraction between pointers from different arrays: 'param:e' and 'param:s'", "rule_id": "ARR36-C", "severity": "High", "suggestion": "Ensure both pointers refer to the same array before subtraction"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 893, "message": "Argument to 'isdigit()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isdigit((unsigned char)...)'"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 894, "message": "Variable 'cap' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'cap' before use, e.g., at its declaration"}, {"column": 43, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 895, "message": "Pointer dereference '*p' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 43, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 895, "message": "Pointer dereference '*p' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 44, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 895, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 44, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 895, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 895, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 895, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 56, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 895, "message": "'e' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 59, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 895, "message": "Pointer dereference '*cap' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 60, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 895, "message": "'cap' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 938, "message": "Pointer subtraction between pointers from different arrays: 'param:e' and 'param:s'", "rule_id": "ARR36-C", "severity": "High", "suggestion": "Ensure both pointers refer to the same array before subtraction"}, {"column": 55, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 958, "message": "Variable 'srcl' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'srcl' before use, e.g., at its declaration"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 959, "message": "Potential null pointer dereference of variable 'p'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'p' is not NULL before dereferencing"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 959, "message": "Pointer dereference '*p' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 959, "message": "Pointer dereference '*p' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 959, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 959, "message": "'p' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 971, "message": "Variable 'lp' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'lp' before use, e.g., at its declaration"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 975, "message": "Variable(s) 'e' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 975, "message": "Static variable 'match' used without explicit initialization", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'match' before use, e.g., at its declaration"}, {"column": 45, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 975, "message": "Variable 'e' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'e' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1029, "message": "Potentially unsafe array access with unvalidated function parameter index 'n'", "rule_id": "ARR30-C", "severity": "High", "suggestion": "Add bounds checking for function parameter before using as array index."}, {"column": 29, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1051, "message": "Variable 'L_NBFD' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1051, "message": "Shift operation '1 << L_NBFD' by 'L_NBFD' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'L_NBFD' is >= 0 and < the bit width of the operand before shifting"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1052, "message": "Variable 'e' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'e' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1059, "message": "Using sprintf return value without error checking; use sprintf_m or check for negative return", "rule_id": "ERR02-C", "severity": "Medium", "suggestion": "Check return value for errors before using it"}, {"column": 40, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1059, "message": "Unsigned subtraction 'sz - n' without guard assumes non-negative result", "rule_id": "INT00-C", "severity": "Medium", "suggestion": "Add a guard: if (a >= b) before unsigned subtraction a - b"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1068, "message": "'buff' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1072, "message": "Argument to 'toupper()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'toupper((unsigned char)...)'"}, {"column": 51, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1132, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1139, "message": "Argument to 'iscntrl()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'iscntrl((unsigned char)...)'"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1141, "message": "Argument to 'isdigit()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isdigit((unsigned char)...)'"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1170, "message": "'buff' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1176, "message": "Pointer dereference '*ppoint' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1221, "message": "Argument to 'isdigit()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isdigit((unsigned char)...)'"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1223, "message": "Argument to 'isdigit()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isdigit((unsigned char)...)'"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1241, "message": "Potential null pointer dereference of variable 'spec'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'spec' is not NULL before dereferencing"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1242, "message": "Variable 'spec' of type char used in numeric operation. Use explicit 'signed char' or 'unsigned char' for numeric values.", "rule_id": "INT07-C", "severity": "Medium", "suggestion": "Change declaration of 'spec' from 'char' to 'signed char' or 'unsigned char'"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1246, "message": "Argument to 'isalpha()' is not cast to unsigned char. This can cause undefined behavior if the argument has a negative value.", "rule_id": "STR37-C", "severity": "Medium", "suggestion": "Cast the argument to unsigned char: 'isalpha((unsigned char)...)'"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1258, "message": "'strfrmt' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1263, "message": "Pointer dereference '*(form++)' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1264, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1264, "message": "memcpy used for string copying may not include null terminator", "rule_id": "STR31-C", "severity": "Medium", "suggestion": "Use strcpy/strncpy or memcpy with size+1 for null terminator"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1274, "message": "'form' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1275, "message": "'lenmod' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1277, "message": "Potential buffer overflow with strcpy(). Cannot verify destination buffer is large enough.", "rule_id": "STR31-C", "severity": "Medium", "suggestion": "Use strncpy() with explicit size limit or verify buffer size"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1277, "message": "Do not cast away const qualification: 'form + l - 1'", "rule_id": "EXP05-C", "severity": "Medium", "suggestion": "Ensure const-qualified objects are not modified through cast-away pointers"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1288, "message": "Variable 'sfl' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'sfl' before use, e.g., at its declaration"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1293, "message": "Potential null pointer dereference of variable 'strfrmt'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'strfrmt' is not NULL before dereferencing"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1298, "message": "Fixed-size buffer may be used with environment variable", "rule_id": "ENV01-C", "severity": "High", "suggestion": "Use dynamic allocation based on strlen() of getenv() result"}, {"column": 6, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1305, "message": "Dereferencing pointer in switch statement may create double-fetch vulnerability", "rule_id": "CON43-C", "severity": "High", "suggestion": "Store dereferenced value in a local variable or use atomic operations"}, {"column": 42, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1365, "message": "Passing potentially null pointer 's' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before passing to function"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1459, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1476, "message": "Pointer parameter 'h' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *h'"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1476, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1477, "message": "'fmt' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1488, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 49, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1498, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1501, "message": "Pointer dereference '*fmt' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1501, "message": "Pointer dereference '*((*fmt)++)' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1501, "message": "Pointer dereference '*fmt' (char type) converted without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1501, "message": "'fmt' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 68, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1551, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1552, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 35, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1570, "message": "Variable 'align' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 29, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1571, "message": "Variable 'szmoda' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1571, "message": "Unsigned subtraction 'align - szmoda' without guard assumes non-negative result", "rule_id": "INT00-C", "severity": "Medium", "suggestion": "Add a guard: if (a >= b) before unsigned subtraction a - b"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1588, "message": "Potential null pointer dereference in array access of variable 'buff'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'buff' is not NULL before array access"}, {"column": 42, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1588, "message": "Bitwise operator '&' used on signed operand 'n' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'n' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 48, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1591, "message": "Bitwise operator '&' used on signed operand 'n' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'n' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1612, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1612, "message": "Pointer dereference '*(dest--)' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1612, "message": "Pointer dereference '*src' (char type) assigned to larger type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment: (unsigned char)*ptr"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1612, "message": "Pointer dereference '*(src++)' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1630, "message": "Variable 'size' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'size' before use, e.g., at its declaration"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1630, "message": "Variable 'size' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 29, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1630, "message": "Variable 'ntoalign' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ntoalign' before use, e.g., at its declaration"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1638, "message": "Identifier 'n' at line 1638 is visually similar to 'h' at line 1619 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 29, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1640, "message": "Shift operation '(lua_Integer)1 << ((size * NB) - 1)' by '((size * NB) - 1)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '((size * NB) - 1)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1647, "message": "Identifier 'n' at line 1647 is visually similar to 'h' at line 1619 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1649, "message": "Shift operation '(lua_Unsigned)1 << (size * NB)' by '(size * NB)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(size * NB)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 19, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1655, "message": "Floating-point conversion to 'float' without range checking", "rule_id": "FLP34-C", "severity": "Medium", "suggestion": "Check for isnan(), compare with FLT_MAX/FLT_MIN or DBL_MAX/DBL_MIN before conversion"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1671, "message": "Floating-point conversion to 'double' without range checking", "rule_id": "FLP34-C", "severity": "Medium", "suggestion": "Check for isnan(), compare with FLT_MAX/FLT_MIN or DBL_MAX/DBL_MIN before conversion"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1686, "message": "Passing potentially null pointer 'buff' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'buff' is not NULL before passing to function"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1695, "message": "Shift operation '(lua_Unsigned)1 << (size * NB)' by '(size * NB)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(size * NB)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1706, "message": "Passing potentially null pointer 's' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before passing to function"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1734, "message": "Variable 'size' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'size' before use, e.g., at its declaration"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1734, "message": "Variable 'ntoalign' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ntoalign' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1758, "message": "Variable 'res' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 60, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1759, "message": "Variable 'size' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 27, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1763, "message": "Shift operation '(lua_Unsigned)1 << (size*NB - 1)' by '(size*NB - 1)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(size*NB - 1)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1764, "message": "Variable 'mask' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1764, "message": "Bitwise operator '^' used on signed operand 'mask' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'mask' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1783, "message": "Variable 'ld' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ld' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1784, "message": "Identifier 'n' at line 1784 is visually similar to 'h' at line 1779 (normalized: 'n')", "rule_id": "DCL02-C", "severity": "Low", "suggestion": "Use a more distinct identifier name that doesn't rely on visually similar characters"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1791, "message": "Variable 'ntoalign' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ntoalign' before use, e.g., at its declaration"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1791, "message": "Variable 'size' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'size' before use, e.g., at its declaration"}, {"column": 29, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1836, "message": "'data' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1856, "message": "Array declaration 'strlib[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1887, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1895, "message": "Function 'luaopen_string' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lstrlib.c", "line": 1895, "message": "Function 'luaopen_string' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_string"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 99, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (luaM_limitN(1 << MAXHBITS, Node))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 106, "message": "Function-like macro 'hashpow2' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 106, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 112, "message": "Function-like macro 'hashmod' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 112, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 21, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 148, "message": "Variable 'sizenode' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 21, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 148, "message": "Variable 't' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 21, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 148, "message": "Division or modulo by 'cast_int((sizenode(t)-1) | 1)' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'cast_int((sizenode(t)-1) | 1)' is not zero before division"}, {"column": 34, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 148, "message": "Modulo operator used with potentially signed operands. The result of % with negative operands is implementation-defined and can be negative. Use unsigned types (size_t, unsigned int) or explicitly handle negative remainders.", "rule_id": "INT10-C", "severity": "Medium", "suggestion": "Convert operands to unsigned types (size_t, unsigned int) or add explicit checks for negative values"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 226, "message": "Function 'mainpositionfromnode' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 226, "message": "Function 'mainpositionfromnode' does not validate pointer parameter 'nd' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'nd' at the start of the function, e.g., 'if (!nd) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 226, "message": "Function 'mainpositionfromnode' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline mainpositionfromnode"}, {"column": 60, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 226, "message": "Pointer parameter 'nd' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *nd'"}, {"column": 14, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 256, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 16, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 272, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 16, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 278, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 291, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 326, "message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 361, "message": "Function 'luaH_next' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 361, "message": "Function 'luaH_next' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 28, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 397, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 479, "message": "Function 'arraykeyisempty' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 479, "message": "Function 'arraykeyisempty' does not validate integer parameter 'key' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'key' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 479, "message": "Function 'arraykeyisempty' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline arraykeyisempty"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 479, "message": "Function 'arraykeyisempty' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'arraykeyisempty'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 544, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 12, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 548, "message": "Scaled integer arithmetic with pointer: 'size * (sizeof(Value) + 1) + sizeof(unsigned)'. This results in double scaling", "rule_id": "ARR39-C", "severity": "High", "suggestion": "Remove sizeof() or use unscaled integer arithmetic"}, {"column": 49, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 563, "message": "Pointer parameter 't' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *t'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 602, "message": "Function 'setnodevector' participates in indirect recursion: setnodevector -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaH_new -> setnodevector", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 30, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 611, "message": "Shift operation '1 << lsize' by 'lsize' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'lsize' is >= 0 and < the bit width of the operand before shifting"}, {"column": 35, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 611, "message": "Bitwise operator '<<' used on signed operand 'lsize' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'lsize' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 22, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 617, "message": "Scaled integer arithmetic with pointer: 'size * sizeof(Node) + sizeof(Limbox)'. This results in double scaling", "rule_id": "ARR39-C", "severity": "High", "suggestion": "Remove sizeof() or use unscaled integer arithmetic"}, {"column": 22, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 619, "message": "Scaled integer arithmetic with pointer: 'Node *, node + sizeof(Limbox)'. This results in double scaling", "rule_id": "ARR39-C", "severity": "High", "suggestion": "Remove sizeof() or use unscaled integer arithmetic"}, {"column": 24, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 620, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 5, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 623, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 17, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 625, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 53, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 667, "message": "Bitwise operator '|' used on signed operand 'bitdummy1' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'bitdummy1' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 715, "message": "Function 'luaH_resize' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 715, "message": "Function 'luaH_resize' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 715, "message": "Function 'luaH_resize' participates in indirect recursion: luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaH_resizearray -> luaH_resize", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 750, "message": "Function 'luaH_resizearray' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 750, "message": "Function 'luaH_resizearray' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 750, "message": "Function 'luaH_resizearray' participates in indirect recursion: luaH_resizearray -> luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaH_resizearray", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 761, "message": "Function 'rehash' participates in indirect recursion: rehash -> luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_set -> luaH_finishset -> luaH_newkey -> rehash", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 35, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 767, "message": "Variable 'ct' may be used uninitialized (not assigned on all paths)", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'ct' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 787, "message": "Variable 'nsize' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 798, "message": "Function 'luaH_new' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 798, "message": "Function 'luaH_new' participates in indirect recursion: luaH_new -> setnodevector -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaH_new", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 806, "message": "Function returns pointer to local variable 't' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 810, "message": "Function 'luaH_size' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 821, "message": "Function 'luaH_free' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 821, "message": "Function 'luaH_free' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 823, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 823, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 21, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 823, "message": "Use-after-free: accessing member of freed pointer 't'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 824, "message": "Double-free: 't' freed multiple times", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Set pointer to NULL after freeing to prevent double-free."}, {"column": 12, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 831, "message": "Double-free: 't' freed multiple times", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Set pointer to NULL after freeing to prevent double-free."}, {"column": 29, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 831, "message": "Use-after-free: accessing member of freed pointer 't'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not access members of freed memory."}, {"column": 22, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 832, "message": "Double-free: 't' freed multiple times", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Set pointer to NULL after freeing to prevent double-free."}, {"column": 18, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 838, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 20, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 840, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 59, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 858, "message": "Pointer parameter 'value' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *value'"}, {"column": 17, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 867, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 14, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 868, "message": "Use-after-free: passing freed pointer 't' to function", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not pass freed memory to functions."}, {"column": 7, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 874, "message": "Direct assignment of flexible array structure instances. Use memcpy() for dynamic copying.", "rule_id": "MEM33-C", "severity": "High", "suggestion": "Use memcpy() to copy the structure and its flexible array member"}, {"column": 12, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 874, "message": "Potential null pointer dereference of variable 'mp'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'mp' is not NULL before dereferencing"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 913, "message": "Function 'luaH_newkey' participates in indirect recursion: luaH_newkey -> rehash -> luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_set -> luaH_finishset -> luaH_newkey", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 958, "message": "Function 'luaH_getint' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 974, "message": "Function 'luaH_Hgetshortstr' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 974, "message": "Function 'luaH_Hgetshortstr' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 974, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 990, "message": "Function 'luaH_getshortstr' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 990, "message": "Function 'luaH_getshortstr' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 990, "message": "Function 'luaH_getshortstr' does not validate pointer parameter 'res' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'res' at the start of the function, e.g., 'if (!res) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1011, "message": "Function 'luaH_getstr' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1011, "message": "Function 'luaH_getstr' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1011, "message": "Function 'luaH_getstr' does not validate pointer parameter 'res' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'res' at the start of the function, e.g., 'if (!res) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1019, "message": "Function 'luaH_get' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1019, "message": "Function 'luaH_get' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1019, "message": "Function 'luaH_get' does not validate pointer parameter 'res' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'res' at the start of the function, e.g., 'if (!res) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1048, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 31, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1048, "message": "Pointer parameter 't' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *t'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1076, "message": "Function 'luaH_psetint' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1076, "message": "Function 'luaH_psetint' does not validate pointer parameter 'val' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'val' at the start of the function, e.g., 'if (!val) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1097, "message": "Function 'luaH_psetshortstr' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1131, "message": "Function 'luaH_pset' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1131, "message": "Function 'luaH_pset' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1131, "message": "Function 'luaH_pset' does not validate pointer parameter 'val' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'val' at the start of the function, e.g., 'if (!val) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1153, "message": "Function 'luaH_finishset' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1153, "message": "Function 'luaH_finishset' participates in indirect recursion: luaH_finishset -> luaS_normstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_set -> luaH_finishset", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 31, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1182, "message": "Variable 'hres' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 13, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1185, "message": "Bitwise operator '~' used on signed operand 'hres' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'hres' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1195, "message": "Function 'luaH_set' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1195, "message": "Function 'luaH_set' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1195, "message": "Function 'luaH_set' does not validate pointer parameter 'value' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'value' at the start of the function, e.g., 'if (!value) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1195, "message": "Function 'luaH_set' participates in indirect recursion: luaH_set -> luaH_finishset -> luaS_normstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_set", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1206, "message": "Function 'luaH_setint' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1206, "message": "Function 'luaH_setint' participates in indirect recursion: luaH_setint -> luaH_newkey -> rehash -> luaH_resize -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab -> luaH_setint", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 19, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1243, "message": "Variable 'n' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 20, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1243, "message": "Shift operation '1u << n' by 'n' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'n' is >= 0 and < the bit width of the operand before shifting"}, {"column": 26, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1243, "message": "Bitwise operator '<<' used on signed operand 'n' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'n' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 19, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1244, "message": "Variable 'mask' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 19, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1244, "message": "Variable 'rnd' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 10, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1262, "message": "Subtracting pointers from different arrays ('j' from 'LUA_MAXINTEGER' and 'i' from 'j'). Pointer subtraction is only defined for pointers within the same array object.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Only subtract pointers that point to elements within the same array object."}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1301, "message": "Function 'luaH_getn' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static lua_Unsigned luaH_getn"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1301, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1351, "message": "Function 'luaH_mainposition' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.c", "line": 1351, "message": "Function 'luaH_mainposition' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 13, "message": "Macro parameter 'i' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'i' in parentheses: (i) instead of i"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 41, "message": "Function-like macro 'allocsizenode' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 41, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 49, "message": "Function-like macro 'luaH_fastgeti' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 49, "message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 49, "message": "Macro parameter 'tag' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'tag' in parentheses: (tag) instead of tag"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 49, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ Table *h = t; lua_Unsigned u = l_castS2U(k) - 1u; \\\n if ((u < h->asize)) { \\\n tag = *getArrTag(h, u); \\\n if (!tagisempty(tag)) { farr2val(h, u, tag, res); }} \\\n else { tag = luaH_getint(h, (k), res); }})"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 49, "message": "Multistatement macro 'luaH_fastgeti' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 49, "message": "Macro evaluates parameter 'k' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 57, "message": "Function-like macro 'luaH_fastseti' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 57, "message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 57, "message": "Macro parameter 'hres' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'hres' in parentheses: (hres) instead of hres"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 57, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ Table *h = t; lua_Unsigned u = l_castS2U(k) - 1u; \\\n if ((u < h->asize)) { \\\n lu_byte *tag = getArrTag(h, u); \\\n if (checknoTM(h->metatable, TM_NEWINDEX) || !tagisempty(*tag)) \\\n { fval2arr(h, u, tag, val); hres = HOK; } \\\n else hres = ~cast_int(u); } \\\n else { hres = luaH_psetint(h, k, val); }})"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 57, "message": "Multistatement macro 'luaH_fastseti' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 57, "message": "Macro evaluates parameter 'k' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 130, "message": "Function-like macro 'arr2obj' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 130, "message": "Macro evaluates parameter 'h' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 133, "message": "Function-like macro 'obj2arr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 133, "message": "Macro evaluates parameter 'h' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 142, "message": "Function-like macro 'farr2val' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 142, "message": "Macro evaluates parameter 'res' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 145, "message": "Function-like macro 'fval2arr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 145, "message": "Macro parameter 'tag' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'tag' in parentheses: (tag) instead of tag"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltable.h", "line": 145, "message": "Macro evaluates parameter 'val' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 34, "message": "Function-like macro 'aux_getn' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 34, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 69, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 76, "message": "Variable 'e' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const e = ..."}, {"column": 38, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 87, "message": "Variable 'pos' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'pos' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 130, "message": "Variable 'e' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const e = ..."}, {"column": 30, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 179, "message": "Variable 'lsep' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'lsep' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 202, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 211, "message": "Variable 'e' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const e = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 214, "message": "Variable(s) 'n' modified and accessed in unsequenced function arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification from the function call"}, {"column": 18, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 214, "message": "Variable(s) 'n' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 18, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 215, "message": "Implicit boolean test on 'lua_checkstack(L, (int)(++n))'. May be unclear what constitutes success or failure.", "rule_id": "EXP20-C", "severity": "Medium", "suggestion": "Use explicit test: lua_checkstack(L, (int)(++n)) == 0 or lua_checkstack(L, (int)(++n)) != 0 depending on success convention"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 297, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 12, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 335, "message": "Variable 'rnd' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 12, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 335, "message": "Division or modulo by '(r4 * 2)' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if '(r4 * 2)' is not zero before division"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 344, "message": "Recursive function can cause excessive stack allocation", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Consider iterative approach or limit recursion depth"}, {"column": 23, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 412, "message": "Array declaration 'tab_funcs[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 425, "message": "Function 'luaopen_table' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltablib.c", "line": 425, "message": "Function 'luaopen_table' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_table"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 1, "message": "Array 'G(L)->tmname' elements allocated in loop but not freed in a matching loop - elements may leak", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Free all elements of 'G(L)->tmname' in a loop with the same bounds"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 30, "message": "Variable 'luaT_typenames_' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 30, "message": "File-scope variable should have minimal scope. Consider making it static within a function or limiting its scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Move variable to the smallest scope where it's used, or make it static inside a function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 38, "message": "Function 'luaT_init' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 28, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 39, "message": "Array declaration 'luaT_eventname[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 23, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 50, "message": "Memory allocated with 'luaS_new' for variable 'G(L)->tmname[i]' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(G(L)->tmname[i])' before the variable goes out of scope"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 60, "message": "Function 'luaT_gettm' does not validate pointer parameter 'events' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'events' at the start of the function, e.g., 'if (!events) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 60, "message": "Function 'luaT_gettm' does not validate pointer parameter 'ename' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ename' at the start of the function, e.g., 'if (!ename) { return error_code; }'"}, {"column": 32, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 64, "message": "Shift operation '1u<<event' by 'event' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that 'event' is >= 0 and < the bit width of the operand before shifting"}, {"column": 8, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 67, "message": "Function returns pointer to local variable 'tm' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 71, "message": "Function 'luaT_gettmbyobj' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 71, "message": "Function 'luaT_gettmbyobj' does not validate pointer parameter 'o' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'o' at the start of the function, e.g., 'if (!o) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 91, "message": "Function 'luaT_objtypename' does not validate pointer parameter 'o' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'o' at the start of the function, e.g., 'if (!o) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 91, "message": "Function 'luaT_objtypename' participates in indirect recursion: luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 103, "message": "Function 'luaT_callTM' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 103, "message": "Function 'luaT_callTM' does not validate pointer parameter 'f' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'f' at the start of the function, e.g., 'if (!f) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 103, "message": "Function 'luaT_callTM' does not validate pointer parameter 'p1' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p1' at the start of the function, e.g., 'if (!p1) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 103, "message": "Function 'luaT_callTM' does not validate pointer parameter 'p2' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p2' at the start of the function, e.g., 'if (!p2) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 103, "message": "Function 'luaT_callTM' does not validate pointer parameter 'p3' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p3' at the start of the function, e.g., 'if (!p3) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 103, "message": "Function 'luaT_callTM' participates in indirect recursion: luaT_callTM -> luaD_callnoyield -> ccall -> luaV_execute -> luaV_finishset -> luaT_callTM", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 119, "message": "Function 'luaT_callTMres' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 119, "message": "Function 'luaT_callTMres' does not validate pointer parameter 'f' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'f' at the start of the function, e.g., 'if (!f) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 119, "message": "Function 'luaT_callTMres' does not validate pointer parameter 'p1' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p1' at the start of the function, e.g., 'if (!p1) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 119, "message": "Function 'luaT_callTMres' does not validate pointer parameter 'p2' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p2' at the start of the function, e.g., 'if (!p2) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 119, "message": "Function 'luaT_callTMres' participates in indirect recursion: luaT_callTMres -> luaD_callnoyield -> ccall -> luaV_execute -> luaV_finishget -> luaT_callTMres", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 138, "message": "Function 'callbinTM' participates in indirect recursion: callbinTM -> luaT_callTMres -> luaD_call -> ccall -> luaV_execute -> luaT_trybiniTM -> luaT_trybinassocTM -> luaT_trybinTM -> callbinTM", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 138, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 150, "message": "Function 'luaT_trybinTM' participates in indirect recursion: luaT_trybinTM -> luaG_tointerror -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_trybiniTM -> luaT_trybinassocTM -> luaT_trybinTM", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 173, "message": "Function 'luaT_tryconcatTM' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 173, "message": "Function 'luaT_tryconcatTM' participates in indirect recursion: luaT_tryconcatTM -> luaG_concaterror -> luaG_typeerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaV_concat -> luaT_tryconcatTM", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 18, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 175, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 44, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 175, "message": "Pointer arithmetic on non-array pointer 'p1'. Only perform arithmetic on array pointers", "rule_id": "ARR37-C", "severity": "High", "suggestion": "Use array indexing or ensure pointer refers to an array"}, {"column": 5, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 176, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 38, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 176, "message": "Pointer arithmetic on non-array pointer 'p1'. Only perform arithmetic on array pointers", "rule_id": "ARR37-C", "severity": "High", "suggestion": "Use array indexing or ensure pointer refers to an array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 180, "message": "Function 'luaT_trybinassocTM' participates in indirect recursion: luaT_trybinassocTM -> luaT_trybinTM -> luaG_opinterror -> luaG_typeerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_trybiniTM -> luaT_trybinassocTM", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 189, "message": "Function 'luaT_trybiniTM' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 189, "message": "Function 'luaT_trybiniTM' does not validate pointer parameter 'p1' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p1' at the start of the function, e.g., 'if (!p1) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 189, "message": "Function 'luaT_trybiniTM' participates in indirect recursion: luaT_trybiniTM -> luaT_trybinassocTM -> luaT_trybinTM -> luaG_opinterror -> luaG_typeerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_trybiniTM", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 200, "message": "Function 'luaT_callorderTM' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 200, "message": "Function 'luaT_callorderTM' does not validate pointer parameter 'p1' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p1' at the start of the function, e.g., 'if (!p1) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 200, "message": "Function 'luaT_callorderTM' does not validate pointer parameter 'p2' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p2' at the start of the function, e.g., 'if (!p2) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 210, "message": "Function 'luaT_callorderiTM' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 210, "message": "Function 'luaT_callorderiTM' does not validate pointer parameter 'p1' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p1' at the start of the function, e.g., 'if (!p1) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 231, "message": "Function 'createvarargtab' participates in indirect recursion: createvarargtab -> luaH_new -> setnodevector -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs -> createvarargtab", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 14, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 234, "message": "Memory allocated with 'luaH_new' for variable 't' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(t)' before the variable goes out of scope"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 272, "message": "Function 'luaT_adjustvarargs' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 272, "message": "Function 'luaT_adjustvarargs' does not validate pointer parameter 'ci' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 272, "message": "Function 'luaT_adjustvarargs' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 272, "message": "Function 'luaT_adjustvarargs' participates in indirect recursion: luaT_adjustvarargs -> createvarargtab -> luaH_new -> setnodevector -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_adjustvarargs", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 292, "message": "Function 'luaT_getvararg' does not validate pointer parameter 'ci' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"}, {"column": 31, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 292, "message": "Pointer parameter 'ci' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ci'"}, {"column": 9, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 305, "message": "Variable 'len' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 321, "message": "Function 'getnumargs' participates in indirect recursion: getnumargs -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_getvarargs -> getnumargs", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 47, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 321, "message": "Pointer parameter 'ci' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ci'"}, {"column": 6, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 322, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 338, "message": "Function 'luaT_getvarargs' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 338, "message": "Function 'luaT_getvarargs' does not validate pointer parameter 'ci' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 338, "message": "Function 'luaT_getvarargs' participates in indirect recursion: luaT_getvarargs -> getnumargs -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaT_getvarargs", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 3, "file": "/home/brandon/toolchain/lua/ltm.c", "line": 340, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.h", "line": 54, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast_byte(~(~0u << (TM_EQ + 1))))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.h", "line": 63, "message": "Function-like macro 'checknoTM' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.h", "line": 63, "message": "Macro evaluates parameter 'mt' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.h", "line": 65, "message": "Function-like macro 'gfasttm' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.h", "line": 65, "message": "Macro parameter 'e' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'e' in parentheses: (e) instead of e"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.h", "line": 65, "message": "Macro evaluates parameter 'mt' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.h", "line": 70, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (luaT_typenames_[(x) + 1])"}, {"column": 1, "file": "/home/brandon/toolchain/lua/ltm.h", "line": 72, "message": "Declaration is missing an explicit type specifier", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Add an explicit type specifier to the declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.c", "line": 42, "message": "Shared variable 'globalL' lacks proper synchronization (not volatile or atomic). This may cause visibility issues across threads.", "rule_id": "CON03-C", "severity": "Medium", "suggestion": "Consider declaring the variable as 'volatile', using atomic types (atomic_int, etc.), or protecting access with mutexes"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lua.c", "line": 57, "message": "sigaction() call detected without apparent signal masking. Ensure sa_mask is properly configured with sigaddset() before calling sigaction().", "rule_id": "SIG00-C", "severity": "High", "suggestion": "Use sigemptyset() and sigaddset() to configure sa_mask before calling sigaction() to prevent race conditions in signal handlers."}, {"column": 44, "file": "/home/brandon/toolchain/lua/lua.c", "line": 70, "message": "Pointer parameter 'ar' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *ar'"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lua.c", "line": 86, "message": "Passing null pointer 'globalL' to 'lua_sethook' which does not check for NULL", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'globalL' is not NULL before passing to 'lua_sethook'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lua.c", "line": 152, "message": "Function 'luaL_traceback' called with same pointer for output and input parameters. If output parameter is non-const restrict, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure output restrict parameter receives a unique pointer"}, {"column": 48, "file": "/home/brandon/toolchain/lua/lua.c", "line": 191, "message": "Pointer parameter 'argv' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *argv'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lua.c", "line": 199, "message": "Passing string literal to function 'lua_setglobal' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lua.c", "line": 233, "message": "Pointer dereference '*modname' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lua.c", "line": 241, "message": "Pointer dereference '*suffix' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lua.c", "line": 255, "message": "Function 'luaL_len' is called without prior declaration", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Declare the function before calling it or include the appropriate header"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lua.c", "line": 258, "message": "Signed integer negation '-i' may overflow (-INT_MIN)", "rule_id": "INT32-C", "severity": "High", "suggestion": "Add check: if (value == INT_MIN) { /* handle error */ }"}, {"column": 46, "file": "/home/brandon/toolchain/lua/lua.c", "line": 264, "message": "Pointer parameter 'argv' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *argv'"}, {"column": 41, "file": "/home/brandon/toolchain/lua/lua.c", "line": 267, "message": "Array subscript -1 is negative. Array indices must be non-negative (0 or greater).", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Array 'argv' requires a non-negative index. Negative indices access memory before the array."}, {"column": 30, "file": "/home/brandon/toolchain/lua/lua.c", "line": 293, "message": "Pointer parameter 'argv' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *argv'"}, {"column": 40, "file": "/home/brandon/toolchain/lua/lua.c", "line": 356, "message": "Pointer parameter 'argv' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *argv'"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lua.c", "line": 360, "message": "'argv' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 22, "file": "/home/brandon/toolchain/lua/lua.c", "line": 394, "message": "Function 'l_getenv' is called without prior declaration", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Declare the function before calling it or include the appropriate header"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lua.c", "line": 397, "message": "Function 'l_getenv' is called without prior declaration", "rule_id": "DCL31-C", "severity": "Low", "suggestion": "Declare the function before calling it or include the appropriate header"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.c", "line": 478, "message": "Shared variable 'l_readline' lacks proper synchronization (not volatile or atomic). This may cause visibility issues across threads.", "rule_id": "CON03-C", "severity": "Medium", "suggestion": "Consider declaring the variable as 'volatile', using atomic types (atomic_int, etc.), or protecting access with mutexes"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.c", "line": 482, "message": "Shared variable 'l_addhist' lacks proper synchronization (not volatile or atomic). This may cause visibility issues across threads.", "rule_id": "CON03-C", "severity": "Medium", "suggestion": "Consider declaring the variable as 'volatile', using atomic types (atomic_int, etc.), or protecting access with mutexes"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lua.c", "line": 490, "message": "Return value of 'fflush' ignored: 'fflush(stdout)' - Can return error indicator", "rule_id": "ERR33-C", "severity": "High", "suggestion": "Check return value for errors"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lua.c", "line": 491, "message": "fgets() without truncation check. Input may be silently truncated.", "rule_id": "FIO20-C", "severity": "Medium", "suggestion": "Check for newline character to detect truncation: if (strchr(buf, '\\n') == NULL) { /* handle truncation */ }"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lua.c", "line": 505, "message": "Freeing parameter 'line'. Memory should be freed at the same abstraction level where it was allocated.", "rule_id": "MEM00-C", "severity": "Medium", "suggestion": "Return error code and let caller handle deallocation"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lua.c", "line": 520, "message": "File descriptor 'lib' opened with open() but never closed with close()", "rule_id": "FIO42-C", "severity": "High", "suggestion": "Add close(lib) before function returns or program exits"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lua.c", "line": 520, "message": "Passing variable 'rllib' (from 'getenv()') to function 'dlopen()' which may modify it.", "rule_id": "ENV30-C", "severity": "Medium", "suggestion": "Copy the return value to a local buffer before passing to functions that may modify it"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lua.c", "line": 524, "message": "Attempting to modify string literal through pointer 'name'", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lua.c", "line": 524, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lua.c", "line": 524, "message": "Pointer dereference '*name' (char type) assigned without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before assignment to larger type"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lua.c", "line": 578, "message": "Variable 'lmsg' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'lmsg' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lua.c", "line": 589, "message": "Fixed-size buffer may be used with environment variable", "rule_id": "ENV01-C", "severity": "High", "suggestion": "Use dynamic allocation based on strlen() of getenv() result"}, {"column": 36, "file": "/home/brandon/toolchain/lua/lua.c", "line": 612, "message": "'retline' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lua.c", "line": 612, "message": "Passing potentially null pointer 'retline' to function", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'retline' is not NULL before passing to function"}, {"column": 52, "file": "/home/brandon/toolchain/lua/lua.c", "line": 612, "message": "'retline' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.c", "line": 638, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 38, "file": "/home/brandon/toolchain/lua/lua.c", "line": 643, "message": "'line' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 44, "file": "/home/brandon/toolchain/lua/lua.c", "line": 643, "message": "Variable 'len' may be used uninitialized (not assigned on all paths)", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len' before use, e.g., at its declaration"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lua.c", "line": 673, "message": "Testing 'lua_gettop(L)' for equality with 1. Functions may return values > 1. Use '!= 0' for boolean-like tests.", "rule_id": "EXP20-C", "severity": "Medium", "suggestion": "Consider using: lua_gettop(L) != 0"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.c", "line": 698, "message": "Function 'doREPL' performs compound operation on shared static variable 'progname' without synchronization", "rule_id": "CON07-C", "severity": "Medium", "suggestion": "Use mutex locks (mtx_lock/mtx_unlock) or atomic operations to ensure atomicity"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lua.c", "line": 711, "message": "Local variable 'oldprogname' assigned to global/static variable 'progname' - creates dangling pointer", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage for local variable or copy data instead of assigning pointer"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lua.c", "line": 711, "message": "Stack pointer escape: local array/VLA assigned to global 'progname'", "rule_id": "MEM30-C", "severity": "Critical", "suggestion": "Do not save pointers to stack-allocated memory in global variables."}, {"column": 26, "file": "/home/brandon/toolchain/lua/lua.c", "line": 735, "message": "'argv' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lua.c", "line": 736, "message": "Variable 'script' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'script' before use, e.g., at its declaration"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lua.c", "line": 739, "message": "Potential null pointer dereference in array access of variable 'argv'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'argv' is not NULL before array access"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lua.c", "line": 742, "message": "Bitwise operator '&' used on signed operand 'args' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'args' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lua.c", "line": 744, "message": "Bitwise operator '&' used on signed operand 'args' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'args' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lua.c", "line": 747, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lua.c", "line": 763, "message": "Bitwise operator '&' used on signed operand 'args' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'args' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 28, "file": "/home/brandon/toolchain/lua/lua.c", "line": 765, "message": "Bitwise operator '&' used on signed operand 'args' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'args' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.c", "line": 777, "message": "Function 'main' does not validate pointer parameter 'argv' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'argv' at the start of the function, e.g., 'if (!argv) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 177, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 178, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 179, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 180, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 181, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 182, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 183, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 185, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 192, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 193, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 194, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 195, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 196, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 197, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 200, "message": "Function has pointer parameter without size argument: 'LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum);' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'int *isnum' to specify the maximum number of elements in the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 200, "message": "Incompatible declarations of function 'lua_Number': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 201, "message": "Function has pointer parameter without size argument: 'LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum);' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'int *isnum' to specify the maximum number of elements in the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 202, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 203, "message": "Function has pointer parameter without size argument: 'LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'size_t *len' to specify the maximum number of elements in the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 205, "message": "Incompatible declarations of function 'lua_CFunction': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 230, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 236, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 237, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 244, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 245, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 65, "file": "/home/brandon/toolchain/lua/lua.h", "line": 246, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lua.h", "line": 248, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 53, "file": "/home/brandon/toolchain/lua/lua.h", "line": 248, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 252, "message": "Variadic function declaration should use proper header", "rule_id": "EXP37-C", "severity": "Medium", "suggestion": "Include proper header instead of declaring variadic function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 253, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 254, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 255, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 256, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 262, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 263, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 264, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 265, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 266, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 267, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 268, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 270, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 272, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 273, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 279, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 280, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 281, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 282, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 283, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 284, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 285, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 286, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 287, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 293, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 297, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 301, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 304, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 310, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 312, "message": "Function has pointer parameter without size argument: 'LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg,' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'int *nres' to specify the maximum number of elements in the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 312, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 314, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 315, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 323, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 324, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 360, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 360, "message": "Variadic function declaration should use proper header", "rule_id": "EXP37-C", "severity": "Medium", "suggestion": "Include proper header instead of declaring variadic function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 367, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 369, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 371, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 372, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 375, "message": "Function has pointer parameter without size argument: 'LUA_API unsigned (lua_numbertocstring) (lua_State *L, int idx, char *buff);' - Add size_t parameter to specify array capacity", "rule_id": "API02-C", "severity": "High", "suggestion": "Add a size_t parameter after 'char *buff' to specify the maximum number of elements in the array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 379, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 381, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 382, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 394, "message": "Macro 'lua_tointeger' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 400, "message": "Function-like macro 'lua_register' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 400, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 423, "message": "Function-like macro 'lua_remove' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 423, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 425, "message": "Function-like macro 'lua_replace' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 425, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 436, "message": "Macro 'lua_newuserdata' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 470, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 471, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 478, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 481, "message": "Incompatible declarations of function 'void': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 483, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lua.h", "line": 484, "message": "Incompatible declarations of function 'int': parameter types differ", "rule_id": "DCL40-C", "severity": "High", "suggestion": "Ensure all declarations of the same function have identical signatures"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lua.h", "line": 504, "message": "String buffer placed before pointer in struct 'lua_Debug': 'char short_src[LUA_IDSIZE];' before 'struct CallInfo *i_ci;' - Buffer overflow could corrupt pointer", "rule_id": "API01-C", "severity": "High", "suggestion": "Move the string buffer 'char short_src' after the pointer field 'struct CallInfo *i_ci;', or use a char* pointer instead of a char array"}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 425, "message": "Macro 'l_floatatt' uses token concatenation operator (##) which prevents parameter expansion - consider using two-level macro indirection for proper expansion", "rule_id": "PRE05-C", "severity": "Low", "suggestion": "Use two-level indirection: define a wrapper macro that calls another macro with ##, allowing parameters to expand first"}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 442, "message": "Macro 'l_floatatt' uses token concatenation operator (##) which prevents parameter expansion - consider using two-level macro indirection for proper expansion", "rule_id": "PRE05-C", "severity": "Low", "suggestion": "Use two-level indirection: define a wrapper macro that calls another macro with ##, allowing parameters to expand first"}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 458, "message": "Macro 'l_floatatt' uses token concatenation operator (##) which prevents parameter expansion - consider using two-level macro indirection for proper expansion", "rule_id": "PRE05-C", "severity": "Low", "suggestion": "Use two-level indirection: define a wrapper macro that calls another macro with ##, allowing parameters to expand first"}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 466, "message": "Macro parameter 'op' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'op' in parentheses: (op) instead of op"}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 602, "message": "Function-like macro 'lua_pointer2str' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 602, "message": "Macro parameter 'p' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'p' in parentheses: (p) instead of p"}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 602, "message": "Macro evaluates parameter 'p' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 626, "message": "Macro parameter 'op' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'op' in parentheses: (op) instead of op"}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 745, "message": "Multistatement macro 'LUAI_MAXALIGN' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/luaconf.h", "line": 748, "message": "Multistatement macro 'LUAI_MAXALIGN' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 45, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 33, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 45, "message": "Pointer parameter 'S' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *S'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 55, "message": "Function-like macro 'loadVector' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 55, "message": "Macro evaluates parameter 'b' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 43, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 57, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 40, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 65, "message": "Division or modulo by 'align' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'align' is not zero before division"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 69, "message": "Division or modulo by 'align' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'align' is not zero before division"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 74, "message": "Function-like macro 'getaddr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 74, "message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 74, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (cast(t *, getaddr_(S,cast_sizet(n) * sizeof(t))))"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 74, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 81, "message": "Function returns pointer to local variable 'block' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 105, "message": "Bitwise operator '|' used on signed operand 'b' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'b' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 106, "message": "Bitwise operator '&' used on signed operand 'b' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'b' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 124, "message": "Variable 'x' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'x' before use, e.g., at its declaration"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 164, "message": "Fixed-size buffer may be used with environment variable", "rule_id": "ENV01-C", "severity": "High", "suggestion": "Use dynamic allocation based on strlen() of getenv() result"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 164, "message": "Variable-length array with runtime-sized allocation; use malloc instead", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Use malloc/calloc for dynamic allocation"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 165, "message": "Macro 'loadVector' may generate array access that cannot be statically analyzed. Macro body: 'loadBlock(S,b,cast_sizet(n)*sizeof((b)[0]))'. Manual review required to ensure bounds safety", "rule_id": "ARR30-C", "severity": "High", "suggestion": "Manually verify that macro expansion does not create out-of-bounds access"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 189, "message": "sizeof applied to pointer/array parameter 'f' which has decayed to a pointer", "rule_id": "ARR01-C", "severity": "High", "suggestion": "Do not use 'sizeof(f->code[0])'. Array/pointer parameters decay to pointers. Pass the array size as a separate parameter instead."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 247, "message": "Function 'loadProtos' participates in indirect recursion: loadProtos -> loadFunction -> loadProtos", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 326, "message": "Function 'loadFunction' participates in indirect recursion: loadFunction -> loadProtos -> loadFunction", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 345, "message": "Variable-length array with runtime-sized allocation; use malloc instead", "rule_id": "MEM05-C", "severity": "Medium", "suggestion": "Use malloc/calloc for dynamic allocation"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 346, "message": "'s' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 347, "message": "Macro 'loadVector' may generate array access that cannot be statically analyzed. Macro body: 'loadBlock(S,b,cast_sizet(n)*sizeof((b)[0]))'. Manual review required to ensure bounds safety", "rule_id": "ARR30-C", "severity": "High", "suggestion": "Manually verify that macro expansion does not create out-of-bounds access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 353, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 371, "message": "Function-like macro 'checknum' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 371, "message": "Macro parameter 'tvar' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'tvar' in parentheses: (tvar) instead of tvar"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 371, "message": "Multistatement macro 'checknum' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 371, "message": "Macro evaluates parameter 'S' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 395, "message": "Function 'luaU_undump' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 395, "message": "Function 'luaU_undump' does not validate pointer parameter 'Z' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'Z' at the start of the function, e.g., 'if (!Z) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 395, "message": "Function 'luaU_undump' does not validate pointer parameter 'anchor' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'anchor' at the start of the function, e.g., 'if (!anchor) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 395, "message": "Function 'luaU_undump' does not validate pointer parameter 'name' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'name' at the start of the function, e.g., 'if (!name) { return error_code; }'"}, {"column": 42, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 395, "message": "Pointer parameter 'Z' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *Z'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 413, "message": "Potential null pointer dereference in member access of variable 'cl'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'cl' is not NULL before member access"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lundump.c", "line": 419, "message": "Function returns pointer to local variable 'cl' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lundump.h", "line": 20, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (-0x5678)"}, {"column": 25, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 53, "message": "Array declaration 'limits[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 55, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 13, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 70, "message": "Variable 'count' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 37, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 70, "message": "Bitwise operator '<<' used on signed operand 'count' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'count' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 10, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 81, "message": "Pointer arithmetic 's + 1' goes 1 elements past the end of array 's[0]'. This exceeds array bounds.", "rule_id": "ARR00-C", "severity": "Medium", "suggestion": "Ensure pointer arithmetic stays within array bounds (0 to 0)"}, {"column": 59, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 94, "message": "Variable 'len' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 97, "message": "Variable(s) 'posi' modified and accessed in unsequenced function arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification from the function call"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 97, "message": "Variable(s) 'posi' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 59, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 123, "message": "Variable 'len' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len' before use, e.g., at its declaration"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 142, "message": "Variable 'code' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'code' before use, e.g., at its declaration"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 185, "message": "Variable 'len' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len' before use, e.g., at its declaration"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 187, "message": "Variable(s) 'posi' modified and accessed in unsequenced function arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification from the function call"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 187, "message": "Variable(s) 'posi' modified and accessed without sequence point", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Separate the modification into a separate statement"}, {"column": 32, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 191, "message": "Variable 'posi' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 32, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 191, "message": "Variable 's' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 8, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 219, "message": "Potential null pointer dereference in array access of variable 's'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 's' is not NULL before array access"}, {"column": 8, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 219, "message": "Plain 'char' variable 's' used in bit operation (signedness issues)", "rule_id": "STR00-C", "severity": "Medium", "suggestion": "Declare 's' as 'unsigned char' for bit operations"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 235, "message": "Variable 'len' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'len' before use, e.g., at its declaration"}, {"column": 34, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 246, "message": "Variable 'code' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'code' before use, e.g., at its declaration"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 276, "message": "Array declaration 'funcs[]' has implicit bounds; specify explicit size", "rule_id": "ARR02-C", "severity": "Medium", "suggestion": "Explicitly specify array bounds even when using an initializer"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 288, "message": "Function 'luaopen_utf8' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 288, "message": "Function 'luaopen_utf8' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_utf8"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lutf8lib.c", "line": 291, "message": "Passing string literal to function 'lua_setfield' which may modify it", "rule_id": "STR30-C", "severity": "High", "suggestion": "Use a modifiable array instead of a string literal"}, {"column": 6, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 68, "message": "Shift operation '(((LUA_MAXINTEGER >> (NBM / 4)) >> (NBM / 4)) >> (NBM / 4)) \\\n\t>> (NBM - (3 * (NBM / 4)))' by '(NBM - (3 * (NBM / 4)))' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(NBM - (3 * (NBM / 4)))' is >= 0 and < the bit width of the operand before shifting"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 68, "message": "Shift operation '((LUA_MAXINTEGER >> (NBM / 4)) >> (NBM / 4)) >> (NBM / 4)' by '(NBM / 4)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(NBM / 4)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 8, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 68, "message": "Shift operation '(LUA_MAXINTEGER >> (NBM / 4)) >> (NBM / 4)' by '(NBM / 4)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(NBM / 4)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 68, "message": "Shift operation 'LUA_MAXINTEGER >> (NBM / 4)' by '(NBM / 4)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(NBM / 4)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 40, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 99, "message": "Variable 'stlen' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'stlen' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 126, "message": "Function 'luaV_flttointeger' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 142, "message": "Function 'luaV_tointegerns' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 157, "message": "Function 'luaV_tointeger' does not validate pointer parameter 'obj' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'obj' at the start of the function, e.g., 'if (!obj) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 157, "message": "Function 'luaV_tointeger' does not validate pointer parameter 'p' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 181, "message": "Function 'forlimit' participates in indirect recursion: forlimit -> luaG_forerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> forprep -> forlimit", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 214, "message": "Function 'forprep' participates in indirect recursion: forprep -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> forprep", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 27, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 229, "message": "Variable 'limit' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'limit' before use, e.g., at its declaration"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 231, "message": "Compound assignment with 'l_castS2U(step)' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'l_castS2U(step)' is not zero before division"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 236, "message": "Compound assignment with 'l_castS2U(-(step + 1)) + 1u' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'l_castS2U(-(step + 1)) + 1u' is not zero before division"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 239, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 252, "message": "Variable 'step' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'step' before use, e.g., at its declaration"}, {"column": 49, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 254, "message": "Variable 'init' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'init' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 291, "message": "Function 'luaV_finishget' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 291, "message": "Function 'luaV_finishget' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 291, "message": "Function 'luaV_finishget' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 291, "message": "Function 'luaV_finishget' participates in indirect recursion: luaV_finishget -> luaT_callTMres -> luaD_call -> ccall -> luaV_execute -> luaV_finishget", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 334, "message": "Function 'luaV_finishset' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 334, "message": "Function 'luaV_finishset' does not validate pointer parameter 't' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 't' at the start of the function, e.g., 'if (!t) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 334, "message": "Function 'luaV_finishset' does not validate pointer parameter 'key' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'key' at the start of the function, e.g., 'if (!key) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 334, "message": "Function 'luaV_finishset' does not validate pointer parameter 'val' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'val' at the start of the function, e.g., 'if (!val) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 334, "message": "Function 'luaV_finishset' participates in indirect recursion: luaV_finishset -> luaH_finishset -> luaS_normstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaV_finishset", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 340, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 391, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 397, "message": "'s1' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 30, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 397, "message": "'s2' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 27, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 401, "message": "'s1' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 27, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 402, "message": "'s2' (signed/plain char) converted to larger integer type without cast to 'unsigned char' - may cause sign extension", "rule_id": "STR34-C", "severity": "Medium", "suggestion": "Cast to 'unsigned char' before conversion to larger type"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 403, "message": "Variable 'rl2' may be used uninitialized (not assigned on all paths)", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'rl2' before use, e.g., at its declaration"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 404, "message": "Variable 'rl1' may be used uninitialized (not assigned on all paths)", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'rl1' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 426, "message": "Function 'LTintfloat' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline LTintfloat"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 426, "message": "Function 'LTintfloat' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'LTintfloat'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 426, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 443, "message": "Function 'LEintfloat' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline LEintfloat"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 443, "message": "Function 'LEintfloat' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'LEintfloat'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 443, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 460, "message": "Function 'LTfloatint' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline LTfloatint"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 460, "message": "Function 'LTfloatint' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'LTfloatint'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 460, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 477, "message": "Function 'LEfloatint' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline LEfloatint"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 477, "message": "Function 'LEfloatint' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'LEfloatint'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 477, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 493, "message": "Function 'LTnum' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline LTnum"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 493, "message": "Function 'LTnum' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'LTnum'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 493, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 515, "message": "Function 'LEnum' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static l_sinline LEnum"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 515, "message": "Function 'LEnum' is only used within this file. It should be declared static to minimize scope.", "rule_id": "DCL19-C", "severity": "Low", "suggestion": "Add 'static' storage class to function 'LEnum'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 515, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 540, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 12, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 562, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 582, "message": "Function 'luaV_equalobj' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 582, "message": "Function 'luaV_equalobj' participates in indirect recursion: luaV_equalobj -> luaT_callTMres -> luaD_call -> ccall -> luaV_execute -> luaV_equalobj", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 604, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 622, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 16, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 624, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 627, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 629, "message": "Variable 'tm' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'tm' before use, e.g., at its declaration"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 635, "message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.", "rule_id": "MEM10-C", "severity": "Medium", "suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 657, "message": "Macro 'tostring' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 657, "message": "Function-like macro 'tostring' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 657, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 665, "message": "Function-like macro 'isemptystr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 665, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 47, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 668, "message": "Pointer parameter 'buff' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *buff'"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 674, "message": "Function 'memcpy' called with potentially invalid size calculation", "rule_id": "ARR38-C", "severity": "High", "suggestion": "Ensure size argument does not exceed buffer bounds"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 674, "message": "Variable 'l' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'l' before use, e.g., at its declaration"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 684, "message": "Function 'luaV_concat' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 684, "message": "Function 'luaV_concat' participates in indirect recursion: luaV_concat -> luaS_newlstr -> internshrstr -> growstrtab -> luaC_fullgc -> fullgen -> entergen -> atomic2gen -> finishgencycle -> luaD_checkminstack -> luaD_growstack -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaV_concat", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 712, "message": "Fixed-size buffer may be used with environment variable", "rule_id": "ENV01-C", "severity": "High", "suggestion": "Use dynamic allocation based on strlen() of getenv() result"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 731, "message": "Function 'luaV_objlen' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 731, "message": "Function 'luaV_objlen' does not validate pointer parameter 'rb' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'rb' at the start of the function, e.g., 'if (!rb) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 731, "message": "Function 'luaV_objlen' participates in indirect recursion: luaV_objlen -> luaT_callTMres -> luaD_call -> ccall -> luaV_execute -> luaV_objlen", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 735, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 737, "message": "Variable 'tm' is used uninitialized", "rule_id": "EXP33-C", "severity": "High", "suggestion": "Initialize 'tm' before use, e.g., at its declaration"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 738, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 746, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 766, "message": "Function 'luaV_idiv' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static lua_Integer luaV_idiv"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 767, "message": "Variable 'n' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 773, "message": "Variable 'm' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 773, "message": "Division or modulo by 'n' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'n' is not zero before division"}, {"column": 14, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 774, "message": "Bitwise operator '^' used on signed operand 'n' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'n' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 774, "message": "Division or modulo by 'n' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'n' is not zero before division"}, {"column": 26, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 774, "message": "Modulo operator used with potentially signed operands. The result of % with negative operands is implementation-defined and can be negative. Use unsigned types (size_t, unsigned int) or explicitly handle negative remainders.", "rule_id": "INT10-C", "severity": "Medium", "suggestion": "Convert operands to unsigned types (size_t, unsigned int) or add explicit checks for negative values"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 786, "message": "Function 'luaV_mod' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static lua_Integer luaV_mod"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 787, "message": "Variable 'n' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 793, "message": "Variable 'r' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const r = ..."}, {"column": 21, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 793, "message": "Division or modulo by 'n' without checking for zero", "rule_id": "INT33-C", "severity": "High", "suggestion": "Check if 'n' is not zero before division"}, {"column": 23, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 793, "message": "Modulo operator used with potentially signed operands. The result of % with negative operands is implementation-defined and can be negative. Use unsigned types (size_t, unsigned int) or explicitly handle negative remainders.", "rule_id": "INT10-C", "severity": "Medium", "suggestion": "Convert operands to unsigned types (size_t, unsigned int) or add explicit checks for negative values"}, {"column": 20, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 794, "message": "Variable 'r' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 24, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 794, "message": "Bitwise operator '^' used on signed operand 'n' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'n' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 804, "message": "Function 'luaV_modf' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 804, "message": "Function 'luaV_modf' should be declared static if it doesn't need external linkage", "rule_id": "DCL15-C", "severity": "Low", "suggestion": "Add 'static' storage-class specifier: static lua_Number luaV_modf"}, {"column": 46, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 834, "message": "Pointer parameter 'p' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *p'"}, {"column": 56, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 834, "message": "Pointer parameter 'encup' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *encup'"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 840, "message": "Potential null pointer dereference in member access of variable 'ncl'", "rule_id": "EXP34-C", "severity": "High", "suggestion": "Check if 'ncl' is not NULL before member access"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 855, "message": "Function 'luaV_finishOp' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 934, "message": "Macro parameter 'a' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'a' in parentheses: (a) instead of a"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 935, "message": "Macro parameter 'a' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'a' in parentheses: (a) instead of a"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 936, "message": "Macro parameter 'a' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'a' in parentheses: (a) instead of a"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 937, "message": "Macro parameter 'a' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'a' in parentheses: (a) instead of a"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 944, "message": "Function-like macro 'op_arithI' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 944, "message": "Macro parameter 'iop' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'iop' in parentheses: (iop) instead of iop"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 944, "message": "Macro parameter 'fop' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'fop' in parentheses: (fop) instead of fop"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 944, "message": "Multistatement macro 'op_arithI' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 944, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 963, "message": "Function-like macro 'op_arithf_aux' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 963, "message": "Macro parameter 'fop' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'fop' in parentheses: (fop) instead of fop"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 963, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ \\\n lua_Number n1; lua_Number n2; \\\n if (tonumberns(v1, n1) && tonumberns(v2, n2)) { \\\n StkId ra = RA(i); \\\n pc++; setfltvalue(s2v(ra), fop(L, n1, n2)); \\\n }})"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 963, "message": "Multistatement macro 'op_arithf_aux' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 974, "message": "Multistatement macro 'op_arithf' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 983, "message": "Multistatement macro 'op_arithfK' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 992, "message": "Function-like macro 'op_arith_aux' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 992, "message": "Macro parameter 'iop' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'iop' in parentheses: (iop) instead of iop"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 992, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ \\\n if (ttisinteger(v1) && ttisinteger(v2)) { \\\n StkId ra = RA(i); \\\n lua_Integer i1 = ivalue(v1); lua_Integer i2 = ivalue(v2); \\\n pc++; setivalue(s2v(ra), iop(L, i1, i2)); \\\n } \\\n else op_arithf_aux(L, v1, v2, fop); })"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 992, "message": "Multistatement macro 'op_arith_aux' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 992, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1004, "message": "Multistatement macro 'op_arith' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1013, "message": "Multistatement macro 'op_arithK' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1022, "message": "Function-like macro 'op_bitwiseK' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1022, "message": "Macro parameter 'op' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'op' in parentheses: (op) instead of op"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1022, "message": "Multistatement macro 'op_bitwiseK' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1036, "message": "Function-like macro 'op_bitwise' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1036, "message": "Macro parameter 'op' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'op' in parentheses: (op) instead of op"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1036, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ \\\n TValue *v1 = vRB(i); \\\n TValue *v2 = vRC(i); \\\n lua_Integer i1; lua_Integer i2; \\\n if (tointegerns(v1, &i1) && tointegerns(v2, &i2)) { \\\n StkId ra = RA(i); \\\n pc++; setivalue(s2v(ra), op(i1, i2)); \\\n }})"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1036, "message": "Multistatement macro 'op_bitwise' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1051, "message": "Macro parameter 'opi' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'opi' in parentheses: (opi) instead of opi"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1051, "message": "Macro parameter 'opn' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'opn' in parentheses: (opn) instead of opn"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1051, "message": "Macro parameter 'other' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'other' in parentheses: (other) instead of other"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1051, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ \\\n TValue *ra = vRA(i); \\\n int cond; \\\n TValue *rb = vRB(i); \\\n if (ttisinteger(ra) && ttisinteger(rb)) { \\\n lua_Integer ia = ivalue(ra); \\\n lua_Integer ib = ivalue(rb); \\\n cond = opi(ia, ib); \\\n } \\\n else if (ttisnumber(ra) && ttisnumber(rb)) \\\n cond = opn(ra, rb); \\\n else \\\n Protect(cond = other(L, ra, rb)); \\\n docondjump(); })"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1051, "message": "Multistatement macro 'op_order' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1071, "message": "Macro parameter 'opi' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'opi' in parentheses: (opi) instead of opi"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1071, "message": "Macro parameter 'opf' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'opf' in parentheses: (opf) instead of opf"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1071, "message": "Multistatement macro 'op_orderI' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1110, "message": "Function-like macro 'RKC' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1110, "message": "Macro evaluates parameter 'i' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1114, "message": "Macro parameter 'ci' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'ci' in parentheses: (ci) instead of ci"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1116, "message": "Macro parameter 'ci' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'ci' in parentheses: (ci) instead of ci"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1119, "message": "Multistatement macro 'updatestack' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1127, "message": "Macro parameter 'e' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'e' in parentheses: (e) instead of e"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1127, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: ({ pc += GETARG_sJ(i) + e; updatetrap(ci); })"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1127, "message": "Multistatement macro 'dojump' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1131, "message": "Multistatement macro 'donextjump' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1138, "message": "Function-like macro 'docondjump' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1138, "message": "Macro replacement list should be parenthesized to prevent operator precedence issues.", "rule_id": "PRE02-C", "severity": "Medium", "suggestion": "Wrap the entire replacement list in parentheses: (if (cond != GETARG_k(i)) pc++; else donextjump(ci);)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1138, "message": "Multistatement macro 'docondjump' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1138, "message": "Macro 'docondjump' definition ends with a semicolon. This can cause unexpected behavior when the macro is used.", "rule_id": "PRE11-C", "severity": "Medium", "suggestion": "Remove the trailing semicolon from the macro definition. The semicolon should be added by the macro user, not in the definition."}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1144, "message": "Macro parameter 'ci' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'ci' in parentheses: (ci) instead of ci"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1151, "message": "Function-like macro 'savestate' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1151, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1151, "message": "Macro parameter 'ci' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'ci' in parentheses: (ci) instead of ci"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1151, "message": "Macro evaluates parameter 'ci' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1174, "message": "Function-like macro 'luai_threadyield' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1174, "message": "Multistatement macro 'luai_threadyield' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1174, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1178, "message": "Function-like macro 'checkGC' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1178, "message": "Macro parameter 'L' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'L' in parentheses: (L) instead of L"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1178, "message": "Multistatement macro 'checkGC' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1178, "message": "Macro evaluates parameter 'L' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1194, "message": "Macro parameter 'l' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'l' in parentheses: (l) instead of l"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1198, "message": "Function 'luaV_execute' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1198, "message": "Function 'luaV_execute' does not validate pointer parameter 'ci' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'ci' at the start of the function, e.g., 'if (!ci) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1198, "message": "Function 'luaV_execute' participates in indirect recursion: luaV_execute -> luaV_equalobj -> luaT_callTMres -> luaD_call -> ccall -> luaV_execute", "rule_id": "MSC04-C", "severity": "Medium", "suggestion": "Refactor to eliminate the recursion cycle"}, {"column": 5, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1232, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1233, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1238, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1244, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1247, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1250, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1256, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1263, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1268, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1274, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1279, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1287, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1293, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1300, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1311, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1317, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1325, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1328, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1338, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1349, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1362, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1368, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1379, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1394, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1407, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1410, "message": "Variable 'c' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const c = ..."}, {"column": 15, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1413, "message": "Variable 'b' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1413, "message": "Variable 'b' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1413, "message": "Variable 'b' used with both bitwise and arithmetic operations (reduces code readability)", "rule_id": "INT14-C", "severity": "Medium", "suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"}, {"column": 15, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1413, "message": "Shift operation '1u << (b - 1)' by '(b - 1)' without validating shift amount is non-negative and within type width", "rule_id": "INT34-C", "severity": "Medium", "suggestion": "Check that '(b - 1)' is >= 0 and < the bit width of the operand before shifting"}, {"column": 21, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1413, "message": "Bitwise operator '<<' used on signed operand 'b' of type 'int'. Use unsigned types for bitwise operations", "rule_id": "INT13-C", "severity": "Medium", "suggestion": "Change 'b' to an unsigned type (e.g., 'unsigned int' instead of 'int')"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1421, "message": "Memory allocated with 'luaH_new' for variable 't' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(t)' before the variable goes out of scope"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1421, "message": "Memory allocated with 'luaH_new' for variable 't' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(t)' before the variable goes out of scope"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1421, "message": "Memory allocated with 'luaH_new' for variable 't' is not freed", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Add 'free(t)' before the variable goes out of scope"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1428, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1440, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1444, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1448, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1452, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1456, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1461, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1465, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1469, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1474, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1478, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1482, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1486, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1492, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1496, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 17, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1502, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1506, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1510, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1514, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1518, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1523, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1527, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1531, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1536, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1540, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1544, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1548, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1552, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1556, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1558, "message": "Variable 'pi' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const pi = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1566, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1568, "message": "Variable 'pi' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const pi = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1576, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1578, "message": "Variable 'pi' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const pi = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1586, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1592, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1595, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1601, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1606, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1612, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1621, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1626, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1634, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1640, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1646, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1650, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1658, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1662, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1666, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1674, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 18, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1681, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1687, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1691, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1695, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1699, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1703, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1709, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1720, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1733, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1733, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1737, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1760, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1760, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1763, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1783, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1783, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1785, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1800, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1800, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1802, "message": "Non-void function may reach end without returning a value. Ensure all execution paths have explicit return statements.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add return statements to ensure all execution paths return a value"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1828, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 11, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1828, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1831, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 13, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1838, "message": "Multiple function calls with potential side effects in unsequenced arguments", "rule_id": "EXP30-C", "severity": "High", "suggestion": "Evaluate function calls in separate statements to guarantee ordering"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1849, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1856, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1873, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1873, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1875, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1886, "message": "Function 'setobjs2s' called with overlapping memory regions. If parameters are restrict-qualified, this causes undefined behavior.", "rule_id": "EXP43-C", "severity": "High", "suggestion": "Ensure memory regions do not overlap when using restrict pointers"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1892, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1892, "message": "Potential memory leak: 't' allocated with 'luaH_new' may not be freed due to goto", "rule_id": "MEM31-C", "severity": "High", "suggestion": "Ensure 't' is freed before this goto or at the target label"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1894, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1901, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1905, "message": "Variable 'h' is initialized but never modified, consider const-qualifying it", "rule_id": "DCL00-C", "severity": "Medium", "suggestion": "Add 'const' qualifier: const h = ..."}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1929, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1936, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1943, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1949, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1955, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lvm.c", "line": 1964, "message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.", "rule_id": "MSC37-C", "severity": "Medium", "suggestion": "Add a return statement on all execution paths of this function"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 51, "message": "Function-like macro 'tonumber' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 51, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 56, "message": "Function-like macro 'tonumberns' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 56, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 62, "message": "Macro 'tointeger' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 62, "message": "Function-like macro 'tointeger' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 62, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 68, "message": "Macro 'tointegerns' reverses parameter order, creating inconsistent interface", "rule_id": "API03-C", "severity": "Medium", "suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 68, "message": "Function-like macro 'tointegerns' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 68, "message": "Macro evaluates parameter 'o' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 73, "message": "Macro parameter 'op' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'op' in parentheses: (op) instead of op"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 81, "message": "Function-like macro 'luaV_fastget' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 81, "message": "Macro parameter 'f' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'f' in parentheses: (f) instead of f"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 81, "message": "Macro parameter 'tag' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'tag' in parentheses: (tag) instead of tag"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 81, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 89, "message": "Function-like macro 'luaV_fastgeti' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 89, "message": "Macro parameter 'tag' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'tag' in parentheses: (tag) instead of tag"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 89, "message": "Multistatement macro 'luaV_fastgeti' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 89, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 94, "message": "Function-like macro 'luaV_fastset' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 94, "message": "Macro parameter 'hres' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'hres' in parentheses: (hres) instead of hres"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 94, "message": "Macro parameter 'f' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'f' in parentheses: (f) instead of f"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 94, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 97, "message": "Function-like macro 'luaV_fastseti' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 97, "message": "Macro parameter 'hres' is not parenthesized in replacement text. This can cause operator precedence issues.", "rule_id": "PRE01-C", "severity": "Medium", "suggestion": "Wrap parameter 'hres' in parentheses: (hres) instead of hres"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 97, "message": "Multistatement macro 'luaV_fastseti' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces", "rule_id": "PRE10-C", "severity": "Medium", "suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lvm.h", "line": 97, "message": "Macro evaluates parameter 't' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 39, "message": "Function 'luaZ_init' does not validate pointer parameter 'L' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 39, "message": "Function 'luaZ_init' does not validate pointer parameter 'z' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'z' at the start of the function, e.g., 'if (!z) { return error_code; }'"}, {"column": 27, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 39, "message": "Pointer parameter 'L' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *L'"}, {"column": 63, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 39, "message": "Pointer parameter 'data' is not modified and should be declared const", "rule_id": "DCL13-C", "severity": "Low", "suggestion": "Declare parameter as 'const <type> *data'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 63, "message": "Function 'luaZ_read' does not validate pointer parameter 'z' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'z' at the start of the function, e.g., 'if (!z) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 63, "message": "Function 'luaZ_read' does not validate pointer parameter 'b' before use", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add validation check for 'b' at the start of the function, e.g., 'if (!b) { return error_code; }'"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 63, "message": "Function 'luaZ_read' does not validate integer parameter 'n' for overflow before arithmetic operations", "rule_id": "API00-C", "severity": "Medium", "suggestion": "Add overflow validation for 'n' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"}, {"column": 32, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 63, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}, {"column": 9, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 66, "message": "Implicit boolean test on 'checkbuffer(z)'. May be unclear what constitutes success or failure.", "rule_id": "EXP20-C", "severity": "Medium", "suggestion": "Use explicit test: checkbuffer(z) == 0 or checkbuffer(z) != 0 depending on success convention"}, {"column": 7, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 81, "message": "Implicit boolean test on 'checkbuffer(z)'. May be unclear what constitutes success or failure.", "rule_id": "EXP20-C", "severity": "Medium", "suggestion": "Use explicit test: checkbuffer(z) == 0 or checkbuffer(z) != 0 depending on success convention"}, {"column": 3, "file": "/home/brandon/toolchain/lua/lzio.c", "line": 88, "message": "Function returns pointer to local variable 'res' with automatic storage duration", "rule_id": "DCL30-C", "severity": "High", "suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.h", "line": 20, "message": "Function-like macro 'zgetc' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.h", "line": 20, "message": "Macro evaluates parameter 'z' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.h", "line": 29, "message": "Function-like macro 'luaZ_initbuffer' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.h", "line": 29, "message": "Macro evaluates parameter 'buff' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.h", "line": 39, "message": "Function-like macro 'luaZ_resizebuffer' evaluates parameter(s) multiple times; prefer inline or static functions for type safety", "rule_id": "PRE00-C", "severity": "Low", "suggestion": null}, {"column": 1, "file": "/home/brandon/toolchain/lua/lzio.h", "line": 39, "message": "Macro evaluates parameter 'buff' multiple times; use inline function instead", "rule_id": "PRE12-C", "severity": "Medium", "suggestion": "Replace macro with inline function to avoid multiple evaluation"}, {"column": 42, "file": "/home/brandon/toolchain/lua/lzio.h", "line": 49, "message": "Pointer parameter should use conformant array syntax", "rule_id": "API05-C", "severity": "High", "suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"}]