summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2020-10-01 20:52:31 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2020-10-01 20:52:31 +0100
commitaf49ffb2b148e146feada9dea59342508414f122 (patch)
treef0366cd3af21954d9970a7d3b1cee802a95723d6
parent93b8a9bba18fc3166dd158484188b1730afdd382 (diff)
downloadlibdom-af49ffb2b148e146feada9dea59342508414f122.tar.gz
libdom-af49ffb2b148e146feada9dea59342508414f122.tar.bz2
html: Check for missing thead rather than dereffing a NULL
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r--src/html/html_tablerow_element.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/html/html_tablerow_element.c b/src/html/html_tablerow_element.c
index fe7d929..569e70f 100644
--- a/src/html/html_tablerow_element.c
+++ b/src/html/html_tablerow_element.c
@@ -244,16 +244,17 @@ dom_exception dom_html_table_row_element_get_row_index(
return exp;
}
- exp = dom_html_table_section_element_get_rows(t_head, &rows);
- dom_node_unref(t_head);
- if (exp != DOM_NO_ERR) {
- return exp;
- }
-
- dom_html_collection_get_length(rows, &len);
- dom_html_collection_unref(rows);
+ if (t_head != NULL) {
+ exp = dom_html_table_section_element_get_rows(t_head, &rows);
+ dom_node_unref(t_head);
+ if (exp != DOM_NO_ERR) {
+ return exp;
+ }
- count += len;
+ dom_html_collection_get_length(rows, &len);
+ dom_html_collection_unref(rows);
+ count += len;
+ }
for (n = n->first_child;n != parent && n != NULL;
n = n->next) {