mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +02:00
check if string msg is not NULL, fix segfault
Origin commit data
------------------
Commit: c9e8a57418
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2016-05-19 (Thu, 19 May 2016)
This commit is contained in:
@@ -56,8 +56,10 @@ bool CLuaMenuChangeObserver::changeNotify(lua_State *L, const std::string &luaAc
|
|||||||
lua_pushstring(L, optionValue);
|
lua_pushstring(L, optionValue);
|
||||||
int status = lua_pcall(L, 2 /* two args */, 1 /* one result */, 0);
|
int status = lua_pcall(L, 2 /* two args */, 1 /* one result */, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, "[CLuaMenuChangeObserver::%s:%d] error in script: %s\n", __func__, __LINE__, lua_tostring(L, -1));
|
bool isString = lua_isstring(L,-1);
|
||||||
DisplayErrorMessage(lua_tostring(L, -1), "Lua Script Error:");
|
const char *null = "NULL";
|
||||||
|
fprintf(stderr, "[CLuaMenuChangeObserver::%s:%d] error in script: %s\n", __func__, __LINE__, isString ? lua_tostring(L, -1): null);
|
||||||
|
DisplayErrorMessage(isString ? lua_tostring(L, -1):null, "Lua Script Error:");
|
||||||
}
|
}
|
||||||
double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0;
|
double res = lua_isnumber(L, -1) ? lua_tonumber(L, -1) : 0;
|
||||||
return (((int)res == menu_return::RETURN_REPAINT) || ((int)res == menu_return::RETURN_EXIT_REPAINT));
|
return (((int)res == menu_return::RETURN_REPAINT) || ((int)res == menu_return::RETURN_EXIT_REPAINT));
|
||||||
@@ -135,8 +137,10 @@ int CLuaMenuForwarder::exec(CMenuTarget* /*parent*/, const std::string & /*actio
|
|||||||
lua_pushstring(L, luaId.c_str());
|
lua_pushstring(L, luaId.c_str());
|
||||||
int status = lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0);
|
int status = lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, "[CLuaMenuForwarder::%s:%d] error in script: %s\n", __func__, __LINE__, lua_tostring(L, -1));
|
bool isString = lua_isstring(L,-1);
|
||||||
DisplayErrorMessage(lua_tostring(L, -1), "Lua Script Error:");
|
const char *null = "NULL";
|
||||||
|
fprintf(stderr, "[CLuaMenuForwarder::%s:%d] error in script: %s\n", __func__, __LINE__, isString ? lua_tostring(L, -1):null);
|
||||||
|
DisplayErrorMessage(isString ? lua_tostring(L, -1):null, "Lua Script Error:");
|
||||||
}
|
}
|
||||||
if (lua_isnumber(L, -1))
|
if (lua_isnumber(L, -1))
|
||||||
res = (int) lua_tonumber(L, -1);
|
res = (int) lua_tonumber(L, -1);
|
||||||
@@ -179,8 +183,10 @@ int CLuaMenuFilebrowser::exec(CMenuTarget* /*parent*/, const std::string& /*acti
|
|||||||
lua_pushstring(L, value->c_str());
|
lua_pushstring(L, value->c_str());
|
||||||
int status = lua_pcall(L, 2 /* two arg */, 1 /* one result */, 0);
|
int status = lua_pcall(L, 2 /* two arg */, 1 /* one result */, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, "[CLuaMenuFilebrowser::%s:%d] error in script: %s\n", __func__, __LINE__, lua_tostring(L, -1));
|
bool isString = lua_isstring(L,-1);
|
||||||
DisplayErrorMessage(lua_tostring(L, -1), "Lua Script Error:");
|
const char *null = "NULL";
|
||||||
|
fprintf(stderr, "[CLuaMenuFilebrowser::%s:%d] error in script: %s\n", __func__, __LINE__, isString ? lua_tostring(L, -1):null);
|
||||||
|
DisplayErrorMessage(isString ? lua_tostring(L, -1):null, "Lua Script Error:");
|
||||||
}
|
}
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
@@ -222,8 +228,10 @@ int CLuaMenuStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*act
|
|||||||
lua_pushstring(L, value->c_str());
|
lua_pushstring(L, value->c_str());
|
||||||
int status = lua_pcall(L, 2 /* two arg */, 1 /* one result */, 0);
|
int status = lua_pcall(L, 2 /* two arg */, 1 /* one result */, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, "[CLuaMenuStringinput::%s:%d] error in script: %s\n", __func__, __LINE__, lua_tostring(L, -1));
|
bool isString = lua_isstring(L,-1);
|
||||||
DisplayErrorMessage(lua_tostring(L, -1), "Lua Script Error:");
|
const char *null = "NULL";
|
||||||
|
fprintf(stderr, "[CLuaMenuStringinput::%s:%d] error in script: %s\n", __func__, __LINE__, isString ? lua_tostring(L, -1):null);
|
||||||
|
DisplayErrorMessage(isString ? lua_tostring(L, -1):null, "Lua Script Error:");
|
||||||
}
|
}
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
}
|
}
|
||||||
@@ -260,8 +268,10 @@ int CLuaMenuKeyboardinput::exec(CMenuTarget* /*parent*/, const std::string & /*a
|
|||||||
lua_pushstring(L, value->c_str());
|
lua_pushstring(L, value->c_str());
|
||||||
int status = lua_pcall(L, 2 /* two arg */, 1 /* one result */, 0);
|
int status = lua_pcall(L, 2 /* two arg */, 1 /* one result */, 0);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, "[CLuaMenuKeyboardinput::%s:%d] error in script: %s\n", __func__, __LINE__, lua_tostring(L, -1));
|
bool isString = lua_isstring(L,-1);
|
||||||
DisplayErrorMessage(lua_tostring(L, -1), "Lua Script Error:");
|
const char *null = "NULL";
|
||||||
|
fprintf(stderr, "[CLuaMenuKeyboardinput::%s:%d] error in script: %s\n", __func__, __LINE__, isString ? lua_tostring(L, -1):null);
|
||||||
|
DisplayErrorMessage(isString ? lua_tostring(L, -1):null, "Lua Script Error:");
|
||||||
}
|
}
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
}
|
}
|
||||||
|
@@ -221,7 +221,9 @@ bool CLuaInstVideo::execLuaInfoFunc(lua_State *L, int xres, int yres, int aspect
|
|||||||
lua_getstack(L, 1, &ar);
|
lua_getstack(L, 1, &ar);
|
||||||
lua_getinfo(L, "Sl", &ar);
|
lua_getinfo(L, "Sl", &ar);
|
||||||
memset(msg, '\0', sizeof(msg));
|
memset(msg, '\0', sizeof(msg));
|
||||||
snprintf(msg, sizeof(msg)-1, "[%s:%d] error running function '%s': %s", ar.short_src, ar.currentline, D->infoFunc.c_str(), lua_tostring(L, -1));
|
bool isString = lua_isstring(L,-1);
|
||||||
|
const char *null = "NULL";
|
||||||
|
snprintf(msg, sizeof(msg)-1, "[%s:%d] error running function '%s': %s", ar.short_src, ar.currentline, D->infoFunc.c_str(), isString ? lua_tostring(L, -1):null);
|
||||||
fprintf(stderr, "[CLuaInstVideo::%s:%d] %s\n", __func__, __LINE__, msg);
|
fprintf(stderr, "[CLuaInstVideo::%s:%d] %s\n", __func__, __LINE__, msg);
|
||||||
DisplayErrorMessage(msg);
|
DisplayErrorMessage(msg);
|
||||||
return false;
|
return false;
|
||||||
|
@@ -435,8 +435,10 @@ void CLuaInstance::runScript(const char *fileName, std::vector<std::string> *arg
|
|||||||
/* run the script */
|
/* run the script */
|
||||||
int status = luaL_loadfile(lua, fileName);
|
int status = luaL_loadfile(lua, fileName);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, "[CLuaInstance::%s] Can't load file: %s\n", __func__, lua_tostring(lua, -1));
|
bool isString = lua_isstring(lua,-1);
|
||||||
DisplayErrorMessage(lua_tostring(lua, -1), "Lua Script Error:");
|
const char *null = "NULL";
|
||||||
|
fprintf(stderr, "[CLuaInstance::%s] Can't load file: %s\n", __func__, isString ? lua_tostring(lua, -1):null);
|
||||||
|
DisplayErrorMessage(isString ? lua_tostring(lua, -1):null, "Lua Script Error:");
|
||||||
if (error_string)
|
if (error_string)
|
||||||
*error_string = std::string(lua_tostring(lua, -1));
|
*error_string = std::string(lua_tostring(lua, -1));
|
||||||
return;
|
return;
|
||||||
@@ -466,8 +468,10 @@ void CLuaInstance::runScript(const char *fileName, std::vector<std::string> *arg
|
|||||||
*result_string = std::string(lua_tostring(lua, -1));
|
*result_string = std::string(lua_tostring(lua, -1));
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, lua_tostring(lua, -1));
|
bool isString = lua_isstring(lua,-1);
|
||||||
DisplayErrorMessage(lua_tostring(lua, -1), "Lua Script Error:");
|
const char *null = "NULL";
|
||||||
|
fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, isString ? lua_tostring(lua, -1):null);
|
||||||
|
DisplayErrorMessage(isString ? lua_tostring(lua, -1):null, "Lua Script Error:");
|
||||||
if (error_string)
|
if (error_string)
|
||||||
*error_string = std::string(lua_tostring(lua, -1));
|
*error_string = std::string(lua_tostring(lua, -1));
|
||||||
/* restoreNeutrino at plugin crash, when blocked from plugin */
|
/* restoreNeutrino at plugin crash, when blocked from plugin */
|
||||||
|
@@ -289,7 +289,9 @@ int CMessageBox::exec(int timeout)
|
|||||||
|
|
||||||
int ShowMsg(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout)
|
int ShowMsg(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout)
|
||||||
{
|
{
|
||||||
std::string tmpText = Text;
|
std::string tmpText = "msg error";
|
||||||
|
if(!Text)
|
||||||
|
tmpText = Text;
|
||||||
CMessageBox* messageBox = new CMessageBox(Caption, tmpText.c_str(), Width, Icon, Default, ShowButtons);
|
CMessageBox* messageBox = new CMessageBox(Caption, tmpText.c_str(), Width, Icon, Default, ShowButtons);
|
||||||
messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout);
|
messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout);
|
||||||
messageBox->exec(timeout);
|
messageBox->exec(timeout);
|
||||||
@@ -301,7 +303,9 @@ int ShowMsg(const neutrino_locale_t Caption, const char * const Text, const CMes
|
|||||||
|
|
||||||
int ShowMsg(const std::string &Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout)
|
int ShowMsg(const std::string &Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout)
|
||||||
{
|
{
|
||||||
std::string tmpText = Text;
|
std::string tmpText = "msg error";
|
||||||
|
if(!Text)
|
||||||
|
tmpText = Text;
|
||||||
CMessageBox* messageBox = new CMessageBox(Caption, tmpText.c_str(), Width, Icon, Default, ShowButtons);
|
CMessageBox* messageBox = new CMessageBox(Caption, tmpText.c_str(), Width, Icon, Default, ShowButtons);
|
||||||
messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout);
|
messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout);
|
||||||
messageBox->exec(timeout);
|
messageBox->exec(timeout);
|
||||||
|
Reference in New Issue
Block a user