Skip to content

Commit 01031c1

Browse files
mohitkhullarclaude
andcommitted
fix lua SPDEBUG NULL dereference on gbl_break_spname
gbl_break_spname can be NULL when debug_sp() sets it from an uninitialized local. Add NULL guards before strcasecmp/strncasecmp in db_debug() and InstructionCountHook() to prevent crash when SET SPDEBUG ON is used without a fully established debug session. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 20fa1da commit 01031c1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lua/sp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ static int db_debug(lua_State *lua)
15781578
sprintf(sp_info, "%s:%s", sp->spname, sp->spversion.version_str);
15791579
}
15801580
len = strlen(sp_info);
1581-
if (strncasecmp(sp_info, gbl_break_spname, len) == 0) {
1581+
if (gbl_break_spname && strncasecmp(sp_info, gbl_break_spname, len) == 0) {
15821582
gbl_break_lua = pthread_self();
15831583
}
15841584
}
@@ -2080,7 +2080,7 @@ static void InstructionCountHook(lua_State *lua, lua_Debug *debug)
20802080
sprintf(sp_info, "%s:%s:%d", sp->spname,
20812081
sp->spversion.version_str, debug->currentline);
20822082
}
2083-
if (strcasecmp(sp_info, gbl_break_spname) == 0) {
2083+
if (gbl_break_spname && strcasecmp(sp_info, gbl_break_spname) == 0) {
20842084
gbl_break_lua = pthread_self();
20852085
}
20862086
}

0 commit comments

Comments
 (0)