aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-11-07 19:24:04 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-11-07 19:24:04 +0300
commitfd8ad72e98f10a8d04380a8c007ae8f68e4a337f (patch)
tree6b23e6a363cbbace2820a796ce00089373d1bc91
parentc28181fe44aefc2c4e31b0d76c50c2793dcc1702 (diff)
downloadrspamd-fd8ad72e98f10a8d04380a8c007ae8f68e4a337f.tar.gz
rspamd-fd8ad72e98f10a8d04380a8c007ae8f68e4a337f.zip
Fix stupid errors while trying to parse NULL address list.
-rw-r--r--src/lua/lua_task.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 887810eb6..8464a6c2f 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -767,11 +767,13 @@ lua_push_internet_address_list (lua_State *L, InternetAddressList *addrs)
gsize len, i;
lua_newtable (L);
- len = internet_address_list_length (addrs);
- for (i = 0; i < len; i ++) {
- ia = internet_address_list_get_address (addrs, i);
- if (lua_push_internet_address (L, ia)) {
- lua_rawseti (L, -2, idx++);
+ if (addrs != NULL) {
+ len = internet_address_list_length (addrs);
+ for (i = 0; i < len; i ++) {
+ ia = internet_address_list_get_address (addrs, i);
+ if (lua_push_internet_address (L, ia)) {
+ lua_rawseti (L, -2, idx++);
+ }
}
}
#endif
@@ -792,17 +794,21 @@ lua_task_get_recipients (lua_State *L)
while (cur) {
#ifndef GMIME24
addrs = internet_address_parse_string (cur->data);
- if (lua_push_internet_address (L, internet_address_list_get_address (addrs))) {
- lua_rawseti (L, -2, idx++);
+ if (addrs) {
+ if (lua_push_internet_address (L, internet_address_list_get_address (addrs))) {
+ lua_rawseti (L, -2, idx++);
+ }
+ internet_address_list_destroy (addrs);
}
- internet_address_list_destroy (addrs);
#else
addrs = internet_address_list_parse_string (cur->data);
- if (lua_push_internet_address (L, internet_address_list_get_address (addrs, 0))) {
- lua_rawseti (L, -2, idx++);
+ if (addrs) {
+ if (lua_push_internet_address (L, internet_address_list_get_address (addrs, 0))) {
+ lua_rawseti (L, -2, idx++);
+ }
+ g_object_unref (addrs);
}
- g_object_unref (addrs);
#endif
cur = g_list_next (cur);
}
@@ -869,7 +875,7 @@ lua_task_get_recipients_headers (lua_State *L)
{
struct worker_task *task = lua_check_task (L);
- if (task) {
+ if (task && task->rcpts) {
lua_push_internet_address_list (L, task->rcpts);
return 1;
}
@@ -890,12 +896,17 @@ lua_task_get_from_headers (lua_State *L)
#else
addrs = internet_address_list_parse_string (g_mime_message_get_sender (task->message));
#endif
- lua_push_internet_address_list (L, addrs);
+ if (addrs) {
+ lua_push_internet_address_list (L, addrs);
#ifndef GMIME24
- internet_address_list_destroy (addrs);
+ internet_address_list_destroy (addrs);
#else
- g_object_unref (addrs);
+ g_object_unref (addrs);
#endif
+ }
+ else {
+ lua_pushnil (L);
+ }
return 1;
}