[aisleriot] cards: svgcrush: Don't leave temp files behind on failure
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aisleriot] cards: svgcrush: Don't leave temp files behind on failure
- Date: Wed, 7 Dec 2011 22:44:24 +0000 (UTC)
commit 3740f1ea3c610786cb4cc47d7d497a35ed5cacde
Author: Christian Persch <chpe gnome org>
Date: Wed Dec 7 23:44:01 2011 +0100
cards: svgcrush: Don't leave temp files behind on failure
cards/svgcrush.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/cards/svgcrush.c b/cards/svgcrush.c
index 11ab99d..a5a4351 100644
--- a/cards/svgcrush.c
+++ b/cards/svgcrush.c
@@ -87,8 +87,13 @@ save (const char *content,
filename = g_strdup ("./svg-crush-XXXXXXXX");
fd = g_mkstemp (filename);
- if (fd == -1 ||
- !g_file_set_contents (filename, decoded, *len, NULL)) {
+ if (fd == -1) {
+ g_free (filename);
+ g_free (decoded);
+ return NULL;
+ }
+ if (!g_file_set_contents (filename, decoded, *len, NULL)) {
+ unlink (filename);
g_free (filename);
g_free (decoded);
return NULL;
@@ -216,7 +221,11 @@ transform (xmlDocPtr doc)
n_nodes = set->nodeNr;
for (i = 0; i < n_nodes; ++i) {
- xmlNodePtr child = nodes[i]->children;
+ xmlNodePtr node = nodes[i];
+ xmlNodePtr child = node->children;
+
+ if (strcmp ((const char *) node->name, "href") != 0)
+ continue;
if (child == NULL ||
child->content == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]