SHA256
1
0
forked from pool/AppStream
AppStream/0002-Don-t-ignore-xmlNodeDump-return-code.patch

45 lines
1.3 KiB
Diff
Raw Normal View History

From 993ea2bc6917327f3f4de421cd8f9594f550ff98 Mon Sep 17 00:00:00 2001
From: Matthias Klumpp <matthias@tenstral.net>
Date: Tue, 30 Jul 2019 02:14:53 +0200
Subject: [PATCH 2/3] Don't ignore xmlNodeDump return code
This should not fail, ever, unless we run out of memory. But since I was
looking at that code, having a sanity check here is better in case this
does become more relevant in future (and simply because not checking it
was not good prectice).
---
src/as-xml.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/as-xml.c b/src/as-xml.c
index 2ba64743..bfa90e72 100644
--- a/src/as-xml.c
+++ b/src/as-xml.c
@@ -94,13 +94,20 @@ as_xml_dump_node_children (xmlNode *node)
str = g_string_new ("");
for (iter = node->children; iter != NULL; iter = iter->next) {
+ gint r;
+
/* discard spaces */
if (iter->type != XML_ELEMENT_NODE) {
- continue;
+ continue;
}
- nodeBuf = xmlBufferCreate();
- xmlNodeDump (nodeBuf, NULL, iter, 0, 1);
+ nodeBuf = xmlBufferCreate ();
+ r = xmlNodeDump (nodeBuf, NULL, iter, 0, 1);
+ if (r < 0) {
+ xmlBufferFree (nodeBuf);
+ g_warning ("xmlNodeDump failed (%i) while serializing node children.", r);
+ continue;
+ }
if (str->len > 0)
g_string_append (str, "\n");
g_string_append_printf (str, "%s", (const gchar*) nodeBuf->content);
--
2.22.0