fix stack handling when getting results
This commit is contained in:
parent
da7bdfa3f9
commit
727137b694
@ -172,10 +172,9 @@ int lua_work(void *handle, void *work_handle, char *input, char *output) {
|
|||||||
|
|
||||||
res = lua_pcall(lwh->l, 1, 2, 0);
|
res = lua_pcall(lwh->l, 1, 2, 0);
|
||||||
|
|
||||||
lua_output = (char*) lua_tostring(lwh->l, lua_gettop(lwh->l));
|
/* peek the result from the stack */
|
||||||
lua_pop(lwh->l, 1);
|
lua_output = (char*) lua_tostring(lwh->l, lua_gettop(lwh->l));
|
||||||
result = lua_tonumber(lwh->l, lua_gettop(lwh->l));
|
result = lua_tonumber(lwh->l, lua_gettop(lwh->l));
|
||||||
lua_pop(lwh->l, 1);
|
|
||||||
|
|
||||||
if (0 != res) {
|
if (0 != res) {
|
||||||
syslog(LOG_ERR, "lua_work: error when calling entrypoint function: %d", res);
|
syslog(LOG_ERR, "lua_work: error when calling entrypoint function: %d", res);
|
||||||
@ -185,5 +184,8 @@ int lua_work(void *handle, void *work_handle, char *input, char *output) {
|
|||||||
snprintf(output, ANSWER_BUFSIZE, lua_output);
|
snprintf(output, ANSWER_BUFSIZE, lua_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* remove the result from the stack */
|
||||||
|
lua_pop(lwh->l, 2);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user