diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-09 16:43:40 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-09 16:43:40 +0000 |
commit | c2cbcd8d98ae8e1b8d1ef06bc6dc53f77ac3bd16 (patch) | |
tree | e8742046ad3eac446a64576f9bfd605e583e9ee5 /src/lua/lua_ip.c | |
parent | dcbe3146b882a731e1cd82025607bd423bb82024 (diff) | |
download | rspamd-c2cbcd8d98ae8e1b8d1ef06bc6dc53f77ac3bd16.tar.gz rspamd-c2cbcd8d98ae8e1b8d1ef06bc6dc53f77ac3bd16.zip |
Fix some issues found by coverity
Diffstat (limited to 'src/lua/lua_ip.c')
-rw-r--r-- | src/lua/lua_ip.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c index 54126f22c..d82de9af9 100644 --- a/src/lua/lua_ip.c +++ b/src/lua/lua_ip.c @@ -358,7 +358,10 @@ lua_ip_from_string (lua_State *L) ip_str = luaL_checkstring (L, 1); if (ip_str) { ip = lua_ip_new (L, NULL); - rspamd_parse_inet_address (&ip->addr, ip_str, 0); + + if (!rspamd_parse_inet_address (&ip->addr, ip_str, 0)) { + msg_warn ("cannot parse ip: %s", ip_str); + } } else { lua_pushnil (L); @@ -525,11 +528,17 @@ rspamd_lua_ip_push_fromstring (lua_State *L, const gchar *ip_str) } else { ip = g_slice_alloc0 (sizeof (struct rspamd_lua_ip)); - rspamd_parse_inet_address (&ip->addr, ip_str, 0); - pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *)); - rspamd_lua_setclass (L, "rspamd{ip}", -1); - *pip = ip; + if (rspamd_parse_inet_address (&ip->addr, ip_str, 0)) { + + pip = lua_newuserdata (L, sizeof (struct rspamd_lua_ip *)); + rspamd_lua_setclass (L, "rspamd{ip}", -1); + *pip = ip; + } + else { + g_slice_free1 (sizeof (*ip), ip); + lua_pushnil (L); + } } } |