Skip to content

Commit db2b19f

Browse files
committed
Add handler for functions not found
Without this, the entire program would SIGSEGV and crash laco. It's also far more helpful to the end user if there is a simple error message to say what is wrong when looking up a function name.
1 parent 4b7195a commit db2b19f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/commands/debugger.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ void laco_print_debug_info(LacoState* laco, const char* function_name) {
2222
/* Walk down the namespace if there is something to go down */
2323
for(i = 0; (namespace = namespaces[i]); i++) {
2424
lua_getfield(L, index, namespace);
25+
2526
index = lua_gettop(L);
27+
28+
if(lua_type(L, index) == LUA_TNIL) {
29+
printf("Couldn't find the function named \"%s\"\n", function_name);
30+
lua_pop(L, i + 1);
31+
32+
return;
33+
}
2634
}
2735

2836
lua_getinfo(L, ">Sl", &debug_info);

0 commit comments

Comments
 (0)