aboutsummaryrefslogtreecommitdiff
path: root/ldblib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-06-09 16:12:01 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-06-09 16:12:01 -0300
commit364e569945c044fd18c70ee1bc851364534aef97 (patch)
treead461207558d0452455a8180cf5d8b1e6e37d0be /ldblib.c
parent63295f1f7fa052fabcb4d69d49203cf33a7deef0 (diff)
downloadlua-364e569945c044fd18c70ee1bc851364534aef97.tar.gz
lua-364e569945c044fd18c70ee1bc851364534aef97.tar.bz2
lua-364e569945c044fd18c70ee1bc851364534aef97.zip
Avoid calling 'fprintf' with NULL
Avoid undefined behavior in calls like «fprintf("%s", NULL)». ('lua_writestringerror' is implemented as 'fprintf', and 'lua_tostring' can return NULL if object is not a string.)
Diffstat (limited to 'ldblib.c')
-rw-r--r--ldblib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ldblib.c b/ldblib.c
index 745cfd27..59eb8f0e 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -417,7 +417,7 @@ static int db_debug (lua_State *L) {
417 return 0; 417 return 0;
418 if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || 418 if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
419 lua_pcall(L, 0, 0, 0)) 419 lua_pcall(L, 0, 0, 0))
420 lua_writestringerror("%s\n", lua_tostring(L, -1)); 420 lua_writestringerror("%s\n", luaL_tolstring(L, -1, NULL));
421 lua_settop(L, 0); /* remove eventual returns */ 421 lua_settop(L, 0); /* remove eventual returns */
422 } 422 }
423} 423}