diff options
author | Daniel Carl <danielcarl@gmx.de> | 2013-03-05 14:00:18 +0100 |
---|---|---|
committer | Daniel Carl <danielcarl@gmx.de> | 2013-03-05 18:02:17 +0100 |
commit | bf27651edee3b143fc70d2f05ee93e6a560afb1d (patch) | |
tree | bf36909b9548d1323dec66611b5cfa8cbdc227e1 /src/dom.c | |
parent | 9a4ddc65abb573eee1329552e65160205f0a3f8f (diff) |
Fixed some memory leaks in completion and dom handling.
Diffstat (limited to 'src/dom.c')
-rw-r--r-- | src/dom.c | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -46,24 +46,28 @@ void dom_check_auto_insert(Client* c) */ gboolean dom_is_editable(Element* element) { + gboolean result = FALSE; if (!element) { - return FALSE; + return result; } char* tagname = webkit_dom_element_get_tag_name(element); - if (!g_ascii_strcasecmp(tagname, "textarea")) { - return TRUE; - } char *type = webkit_dom_element_get_attribute(element, "type"); - if (!g_ascii_strcasecmp(tagname, "input") + if (!g_ascii_strcasecmp(tagname, "textarea")) { + result = TRUE; + } else if (!g_ascii_strcasecmp(tagname, "input") && g_ascii_strcasecmp(type, "submit") && g_ascii_strcasecmp(type, "reset") && g_ascii_strcasecmp(type, "image") ) { - return TRUE; + result = TRUE; + } else { + result = FALSE; } + g_free(tagname); + g_free(type); - return FALSE; + return result; } static gboolean dom_auto_insert(Client* c, Element* element) @@ -91,15 +95,23 @@ static Element* dom_get_active_element(Document* doc) { Document* d = NULL; Element* active = webkit_dom_html_document_get_active_element((void*)doc); - char* tagname = webkit_dom_element_get_tag_name(active); + char* tagname = webkit_dom_element_get_tag_name(active); + Element* result = NULL; if (!g_strcmp0(tagname, "FRAME")) { d = webkit_dom_html_frame_element_get_content_document(WEBKIT_DOM_HTML_FRAME_ELEMENT(active)); - return dom_get_active_element(d); - } - if (!g_strcmp0(tagname, "IFRAME")) { + result = dom_get_active_element(d); + } else if (!g_strcmp0(tagname, "IFRAME")) { d = webkit_dom_html_iframe_element_get_content_document(WEBKIT_DOM_HTML_IFRAME_ELEMENT(active)); - return dom_get_active_element(d); + result = dom_get_active_element(d); } + g_free(tagname); + + if (result) { + g_free(active); + + return result; + } + return active; } |