summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorlvtao-sec <[email protected]>2020-08-22 18:50:00 +0800
committerraveit65 <[email protected]>2020-08-26 13:35:49 +0200
commit9f86b203c1a411dd24b3219c104db16b6ecedc95 (patch)
tree9ef7eb6e06b7bfe67438ddfe5350bae41f51ef09 /backend
parent03693b12f9d76bc16c02d5ac6ff42ad51c7316fa (diff)
downloadatril-9f86b203c1a411dd24b3219c104db16b6ecedc95.tar.bz2
atril-9f86b203c1a411dd24b3219c104db16b6ecedc95.tar.xz
check return value of xmlDocGetRootElement call if is NULL
Diffstat (limited to 'backend')
-rw-r--r--backend/epub/epub-document.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/backend/epub/epub-document.c b/backend/epub/epub-document.c
index 552a18d3..8f97aa9f 100644
--- a/backend/epub/epub-document.c
+++ b/backend/epub/epub-document.c
@@ -181,8 +181,18 @@ epub_document_check_hits(EvDocumentFind *document_find,
{
gchar *filepath = g_filename_from_uri((gchar*)page->backend_page,NULL,NULL);
htmlDocPtr htmldoc = xmlParseFile(filepath);
- htmlNodePtr htmltag = xmlDocGetRootElement(htmldoc);
- int count=0;
+ if (htmldoc == NULL) {
+ g_free(filepath);
+ return 0;
+ }
+ htmlNodePtr htmltag = xmlDocGetRootElement(htmldoc);
+ if (htmltag == NULL) {
+ g_free(filepath);
+ xmlFreeDoc (htmldoc);
+ return 0;
+ }
+
+ int count=0;
htmlNodePtr bodytag = htmltag->xmlChildrenNode;
while ( xmlStrcmp(bodytag->name,(xmlChar*)"body") ) {