[evince/wip/chpe/xmp: 6/11] libdocument: Plug some mem leaks in the XMP parser
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/chpe/xmp: 6/11] libdocument: Plug some mem leaks in the XMP parser
- Date: Sat, 4 Dec 2021 00:45:51 +0000 (UTC)
commit c68c875cf6242dfdb8f6e7c6c09dbcefa7ab65a5
Author: Christian Persch <chpe src gnome org>
Date: Sat Dec 4 01:45:44 2021 +0100
libdocument: Plug some mem leaks in the XMP parser
libdocument/ev-xmp.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
---
diff --git a/libdocument/ev-xmp.c b/libdocument/ev-xmp.c
index bf4f59b29..397dc6449 100644
--- a/libdocument/ev-xmp.c
+++ b/libdocument/ev-xmp.c
@@ -89,8 +89,6 @@ xmp_get_tag_from_xpath (xmlXPathContextPtr xpathCtx,
xmlChar *result = NULL;
char *xmpmetapath;
- xmpmetapath = g_strdup_printf ("%s%s", "/x:xmpmeta", xpath);
-
/* Try in /rdf:RDF/ */
xpathObj = xmlXPathEvalExpression (BAD_CAST xpath, xpathCtx);
if (xpathObj == NULL)
@@ -108,7 +106,9 @@ xmp_get_tag_from_xpath (xmlXPathContextPtr xpathCtx,
Try in /x:xmpmeta/ (xmpmeta is optional)
https://wwwimages2.adobe.com/content/dam/acom/en/devnet/xmp/pdfs/XMP SDK Release
cc-2016-08/XMPSpecificationPart1.pdf (Section 7.3.3)
*/
+ xmpmetapath = g_strdup_printf ("%s%s", "/x:xmpmeta", xpath);
xpathObj = xmlXPathEvalExpression (BAD_CAST xmpmetapath, xpathCtx);
+ g_free (xmpmetapath);
if (xpathObj == NULL)
return NULL;
@@ -116,7 +116,6 @@ xmp_get_tag_from_xpath (xmlXPathContextPtr xpathCtx,
result = xmlNodeGetContent (xpathObj->nodesetval->nodeTab[0]);
xmlXPathFreeObject (xpathObj);
- g_free (xmpmetapath);
return result;
}
@@ -224,7 +223,6 @@ xmp_get_lists_from_dc_tags (xmlXPathContextPtr xpathCtx,
}
xmlXPathFreeObject (xpathObj);
-
if (elements != NULL) {
/* return buffer */
result = g_strdup (elements);
@@ -242,16 +240,13 @@ xmp_get_author (xmlXPathContextPtr xpathCtx)
char* result = NULL;
char* xmpmetapath;
- xmpmetapath = g_strdup_printf ("%s%s", "/x:xmpmeta", AUTHORS);
-
/* Try in /rdf:RDF/ */
result = xmp_get_lists_from_dc_tags (xpathCtx, AUTHORS);
- if (result != NULL) {
- g_free (xmpmetapath);
+ if (result != NULL)
return result;
- }
/* Try in /x:xmpmeta/ */
+ xmpmetapath = g_strdup_printf ("%s%s", "/x:xmpmeta", AUTHORS);
result = xmp_get_lists_from_dc_tags (xpathCtx, xmpmetapath);
g_free (xmpmetapath);
@@ -264,16 +259,13 @@ xmp_get_keywords (xmlXPathContextPtr xpathCtx)
char* result = NULL;
char* xmpmetapath;
- xmpmetapath = g_strdup_printf ("%s%s", "/x:xmpmeta", KEYWORDS);
-
/* Try in /rdf:RDF/ */
result = xmp_get_lists_from_dc_tags (xpathCtx, KEYWORDS);
- if (result != NULL) {
- g_free (xmpmetapath);
+ if (result != NULL)
return result;
- }
/* Try in /x:xmpmeta/ */
+ xmpmetapath = g_strdup_printf ("%s%s", "/x:xmpmeta", KEYWORDS);
result = xmp_get_lists_from_dc_tags (xpathCtx, xmpmetapath);
g_free (xmpmetapath);
@@ -347,10 +339,8 @@ xmp_get_license (xmlXPathContextPtr xpathCtx)
marked = xmp_get_tag_from_xpath (xpathCtx, LICENSE_MARKED);
/* a) Not marked => No XMP Rights information */
- if (!marked) {
- xmlFree (marked);
+ if (!marked)
return NULL;
- }
license = ev_document_license_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]