{
"llimits.h": [
{
"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"
}
],
"lstate.c": [
{
"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; }'"
}
],
"lstring.c": [
{
"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"
}
],
"ltablib.c": [
{
"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"
}
],
"ltm.c": [
{
"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 = ..."
}
],
"lundump.c": [
{
"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"
}
]
}