[librsvg] handle: Call close() after write() even on write error
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] handle: Call close() after write() even on write error
- Date: Sat, 27 Sep 2014 20:04:32 +0000 (UTC)
commit 427aba9237a386cfede184dec35a06788e553f2c
Author: Christian Persch <chpe gnome org>
Date: Thu Sep 18 18:30:10 2014 +0200
handle: Call close() after write() even on write error
Otherwise the internal xmlDoc will leak.
https://bugzilla.gnome.org/show_bug.cgi?id=736825
rsvg-base-file-util.c | 9 ++++-----
rsvg-defs.c | 6 ++++--
rsvg-file-util.c | 2 ++
3 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/rsvg-base-file-util.c b/rsvg-base-file-util.c
index 52d0f70..47dc67f 100644
--- a/rsvg-base-file-util.c
+++ b/rsvg-base-file-util.c
@@ -33,15 +33,14 @@ static gboolean
rsvg_handle_fill_with_data (RsvgHandle * handle,
const guint8 * data, gsize data_len, GError ** error)
{
+ gboolean rv;
+
rsvg_return_val_if_fail (data != NULL, FALSE, error);
rsvg_return_val_if_fail (data_len != 0, FALSE, error);
- if (!rsvg_handle_write (handle, data, data_len, error))
- return FALSE;
- if (!rsvg_handle_close (handle, error))
- return FALSE;
+ rv = rsvg_handle_write (handle, data, data_len, error);
- return TRUE;
+ return rsvg_handle_close (handle, rv ? error : NULL) && rv;
}
/**
diff --git a/rsvg-defs.c b/rsvg-defs.c
index 8e2f98f..006d290 100644
--- a/rsvg-defs.c
+++ b/rsvg-defs.c
@@ -68,6 +68,7 @@ rsvg_defs_load_extern (const RsvgDefs * defs, const char *name)
gchar *filename, *base_uri;
guint8 *data;
gsize data_len;
+ gboolean rv;
filename = _rsvg_io_get_file_path (name, rsvg_handle_get_base_uri (defs->ctx));
@@ -80,8 +81,9 @@ rsvg_defs_load_extern (const RsvgDefs * defs, const char *name)
rsvg_handle_set_base_uri (handle, base_uri);
g_free (base_uri);
- if (rsvg_handle_write (handle, data, data_len, NULL) &&
- rsvg_handle_close (handle, NULL)) {
+ rv = rsvg_handle_write (handle, data, data_len, NULL);
+ rv = rsvg_handle_close (handle, NULL) && rv;
+ if (rv) {
g_hash_table_insert (defs->externs, g_strdup (name), handle);
}
diff --git a/rsvg-file-util.c b/rsvg-file-util.c
index c22413d..827a684 100644
--- a/rsvg-file-util.c
+++ b/rsvg-file-util.c
@@ -66,6 +66,7 @@ rsvg_pixbuf_from_data_with_size_data (const guchar * buff,
rsvg_handle_set_base_uri (handle, base_uri);
if (!rsvg_handle_write (handle, buff, len, error)) {
+ (void) rsvg_handle_close (handle, NULL);
g_object_unref (handle);
return NULL;
}
@@ -102,6 +103,7 @@ rsvg_pixbuf_from_stdio_file_with_size_data (guint8 *data,
rsvg_handle_set_base_uri (handle, base_uri);
if (!rsvg_handle_write (handle, data, data_len, error)) {
+ (void) rsvg_handle_close (handle, NULL);
g_object_unref (handle);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]