[gnome-epub-thumbnailer/wip/hadess/epub-workaround: 2/6] epub: Use g_autofree for root_path




commit 1be6c96cab3703a2c82296795c2c43fe39fa6f25
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Sep 28 17:15:18 2022 +0200

    epub: Use g_autofree for root_path

 gnome-epub-thumbnailer.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/gnome-epub-thumbnailer.c b/gnome-epub-thumbnailer.c
index 7e4114e..a747b63 100644
--- a/gnome-epub-thumbnailer.c
+++ b/gnome-epub-thumbnailer.c
@@ -212,7 +212,7 @@ get_cover_path_from_root_file (const char *metafile,
 {
        xmlDocPtr doc;
        xmlXPathContextPtr xpath_ctx;
-       char *root_path;
+       g_autofree char *root_path = NULL;
        char *root_file;
        gsize root_length;
        char *cover_path, *full_cover_path;
@@ -232,10 +232,8 @@ get_cover_path_from_root_file (const char *metafile,
 
        doc = open_doc (root_file, root_length, "package");
        g_free (root_file);
-       if (!doc) {
-               g_free (root_path);
+       if (!doc)
                return NULL;
-       }
 
        xpath_ctx = xmlXPathNewContext(doc);
        xmlXPathRegisterNs (xpath_ctx, BAD_CAST ("ns"), BAD_CAST (OPF_NAMESPACE));
@@ -267,7 +265,6 @@ get_cover_path_from_root_file (const char *metafile,
        g_debug ("Resolved full_cover_path '%s'", cover_path);
 
 bail:
-       g_free (root_path);
        xmlXPathFreeContext(xpath_ctx);
        xmlFreeDoc (doc);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]