Commit 427aba92 authored by Christian Persch's avatar Christian Persch

handle: Call close() after write() even on write error

Otherwise the internal xmlDoc will leak.

https://bugzilla.gnome.org/show_bug.cgi?id=736825
parent bef6571e
......@@ -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;
}
/**
......
......@@ -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);
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment