diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-15 15:06:07 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-15 15:06:07 +0000 |
commit | f5955b8d3e46fef5065a395ce3f7dade267fba1f (patch) | |
tree | 13d698a7ecd6aed603a048fe478cd3fb630a788b /src/lua/lua_task.c | |
parent | b4fbb32b3dcd21f1fc90c419aa3992ecb6f7924a (diff) | |
download | rspamd-f5955b8d3e46fef5065a395ce3f7dade267fba1f.tar.gz rspamd-f5955b8d3e46fef5065a395ce3f7dade267fba1f.zip |
[Fix] Restore described behaviour for some lua functions
Diffstat (limited to 'src/lua/lua_task.c')
-rw-r--r-- | src/lua/lua_task.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index e5214a321..fa60184ee 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -1843,14 +1843,20 @@ lua_task_get_images (lua_State *L) if (task) { cur = task->images; - lua_newtable (L); + if (cur) { + lua_newtable (L); - while (cur) { - pimg = lua_newuserdata (L, sizeof (struct rspamd_image *)); - rspamd_lua_setclass (L, "rspamd{image}", -1); - *pimg = cur->data; - lua_rawseti (L, -2, i++); - cur = g_list_next (cur); + while (cur) { + pimg = lua_newuserdata (L, sizeof (struct rspamd_image *)); + rspamd_lua_setclass (L, "rspamd{image}", -1); + *pimg = cur->data; + lua_rawseti (L, -2, i++); + cur = g_list_next (cur); + } + } + else { + /* Return nil if there are no images to preserve compatibility */ + lua_pushnil (L); } } else { |