From 1ee46a273ee70404aa3e7d4dbf27baf0b0e906df Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Fri, 22 Jul 2016 17:24:39 +0200 Subject: [PATCH] src/gui/lua/lua_video.cpp fix possible segfault if argument is not a string (nil) Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/021db3ab04ec9964dc2a95b3990f2658f8ce97e1 Author: Jacek Jendrzej Date: 2016-07-22 (Fri, 22 Jul 2016) --- src/gui/lua/lua_video.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/gui/lua/lua_video.cpp b/src/gui/lua/lua_video.cpp index c7df7912d..fd25aeda2 100644 --- a/src/gui/lua/lua_video.cpp +++ b/src/gui/lua/lua_video.cpp @@ -153,6 +153,23 @@ int CLuaInstVideo::PlayFile(lua_State *L) printf("CLuaInstVideo::%s: not enough arguments (%d, expected 3)\n", __func__, numargs); return 0; } + const char *errmsg = "is not a string."; + if(!lua_isstring(L,2)){ + printf("CLuaInstVideo::%s: argument 1 %s\n", __func__, errmsg); + return 0; + } + if(!lua_isstring(L,3)){ + printf("CLuaInstVideo::%s: argument 2 %s\n", __func__, errmsg); + return 0; + } + if(numargs > 3 && !lua_isstring(L,4)){ + printf("CLuaInstVideo::%s: argument 3 %s\n", __func__, errmsg); + return 0; + } + if(numargs > 4 && !lua_isstring(L,5)){ + printf("CLuaInstVideo::%s: argument 4 %s\n", __func__, errmsg); + return 0; + } bool sp = false; if (luaL_testudata(L, 1, LUA_CLASSNAME) == NULL)