summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-19 17:13:00 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-19 17:13:00 +0100
commit14ab88afca52e61e85be5a667a90b5ca4c6905e1 (patch)
treec3f743ea26b15e35a3ba98000d6cbcaa6eecef54 /src
parent6d59a0c87c8b75195c996b5b2dc580c5abb84561 (diff)
downloadrspamd-14ab88afca52e61e85be5a667a90b5ca4c6905e1.tar.gz
rspamd-14ab88afca52e61e85be5a667a90b5ca4c6905e1.zip
[Minor] Do not traverse empty HTML tree
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_html.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/lua/lua_html.c b/src/lua/lua_html.c
index f21432e9f..bad085450 100644
--- a/src/lua/lua_html.c
+++ b/src/lua/lua_html.c
@@ -438,26 +438,28 @@ lua_html_foreach_tag (lua_State *L)
tagname = luaL_checkstring (L, 2);
if (hc && tagname && lua_isfunction (L, 3)) {
- if (strcmp (tagname, "any") == 0) {
- id = -1;
- }
- else {
- id = rspamd_html_tag_by_name (tagname);
+ if (hc->html_tags) {
+ if (strcmp (tagname, "any") == 0) {
+ id = -1;
+ }
+ else {
+ id = rspamd_html_tag_by_name (tagname);
- if (id == -1) {
- return luaL_error (L, "invalid tagname: %s", tagname);
+ if (id == -1) {
+ return luaL_error (L, "invalid tagname: %s", tagname);
+ }
}
- }
- lua_pushvalue (L, 3);
- ud.cbref = luaL_ref (L, LUA_REGISTRYINDEX);
- ud.L = L;
- ud.tag_id = id;
+ lua_pushvalue (L, 3);
+ ud.cbref = luaL_ref (L, LUA_REGISTRYINDEX);
+ ud.L = L;
+ ud.tag_id = id;
- g_node_traverse (hc->html_tags, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
- lua_html_node_foreach_cb, &ud);
+ g_node_traverse (hc->html_tags, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+ lua_html_node_foreach_cb, &ud);
- luaL_unref (L, LUA_REGISTRYINDEX, ud.cbref);
+ luaL_unref (L, LUA_REGISTRYINDEX, ud.cbref);
+ }
}
else {
return luaL_error (L, "invalid arguments");