From d901a9df71935fc98c0ec59bd27658670f3740ee Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:08:38 -0500 Subject: epub: Avoid crash when index list has extraneous entry This commit also fixes an incorrect sizeof call detected by AddressSanitizer. Closes #599 --- backend/epub/epub-document.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backend/epub') diff --git a/backend/epub/epub-document.c b/backend/epub/epub-document.c index 3ea7bdaa..1ac13e60 100644 --- a/backend/epub/epub-document.c +++ b/backend/epub/epub-document.c @@ -1044,7 +1044,7 @@ setup_document_content_list(const gchar* content_uri, GError** error,gchar *docu } if ( xmlStrcmp(itemrefptr->name,(xmlChar*)"itemref") == 0) { - contentListNode *newnode = g_malloc0(sizeof(newnode)); + contentListNode *newnode = g_malloc0(sizeof(*newnode)); newnode->key = (gchar*)xml_get_data_from_node(itemrefptr,XML_ATTRIBUTE,(xmlChar*)"idref"); if ( newnode->key == NULL ) { @@ -1626,7 +1626,7 @@ page_set_function(linknode *Link, GList *contentList) contentListNode *pagedata; guint flag=0; - while (!flag) { + while (!flag && listiter) { pagedata = listiter->data; if (link_present_on_page(Link->pagelink, pagedata->value)) { flag=1; -- cgit v1.2.1