diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-06-09 16:12:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-06-09 16:12:01 -0300 |
commit | 364e569945c044fd18c70ee1bc851364534aef97 (patch) | |
tree | ad461207558d0452455a8180cf5d8b1e6e37d0be /ldblib.c | |
parent | 63295f1f7fa052fabcb4d69d49203cf33a7deef0 (diff) | |
download | lua-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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 | } |