[gnome-epub-thumbnailer] main: Fix crashes when we cannot find cover info
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-epub-thumbnailer] main: Fix crashes when we cannot find cover info
- Date: Sat, 13 Jul 2013 12:28:09 +0000 (UTC)
commit 0fd97b89dd5f0e3c87bf4a39113b981c6b405926
Author: Bastien Nocera <hadess hadess net>
Date: Sat Jul 13 14:26:41 2013 +0200
main: Fix crashes when we cannot find cover info
In the metadata.
gnome-epub-thumbnailer.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/gnome-epub-thumbnailer.c b/gnome-epub-thumbnailer.c
index 21f7ae3..6005e02 100644
--- a/gnome-epub-thumbnailer.c
+++ b/gnome-epub-thumbnailer.c
@@ -139,23 +139,26 @@ get_prop_for_xpath (xmlDocPtr doc,
{
xmlXPathObjectPtr xpath_obj;
xmlNodePtr cur;
- xmlChar *prop;
- char *ret;
+ char *ret = NULL;
xpath_obj = xmlXPathEvalExpression (BAD_CAST (path), xpath_ctx);
if (xpath_obj == NULL)
return NULL;
- if (xpath_obj->nodesetval == NULL) {
- xmlXPathFreeObject (xpath_obj);
- return NULL;
- }
+ if (xpath_obj->nodesetval == NULL ||
+ xpath_obj->nodesetval->nodeTab == NULL)
+ goto bail;
cur = xpath_obj->nodesetval->nodeTab[0];
- prop = xmlGetProp (cur, BAD_CAST (name));
- ret = NULL;
- if (prop) {
- ret = g_strdup ((const char *) prop);
- xmlFree (prop);
+ if (cur != NULL) {
+ xmlChar *prop;
+
+ prop = xmlGetProp (cur, BAD_CAST (name));
+ if (prop) {
+ ret = g_strdup ((const char *) prop);
+ xmlFree (prop);
+ }
}
+
+bail:
xmlXPathFreeObject (xpath_obj);
return ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]