[rhythmbox] ext-db: don't leak strings passed or returned as GStrings
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] ext-db: don't leak strings passed or returned as GStrings
- Date: Wed, 13 Jun 2012 09:19:43 +0000 (UTC)
commit 96aa2cdf837ebf7ca6229b5105ea779603d3316d
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Jun 13 19:16:15 2012 +1000
ext-db: don't leak strings passed or returned as GStrings
g_string_new_len copies the data rather than taking ownership
of it. Manually allocate GStrings and assign the buffers to
them instead.
More huge leaks.
metadata/rb-ext-db.c | 5 ++++-
shell/rb-shell.c | 7 +++++--
2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/metadata/rb-ext-db.c b/metadata/rb-ext-db.c
index d53c257..6abf8d3 100644
--- a/metadata/rb-ext-db.c
+++ b/metadata/rb-ext-db.c
@@ -619,7 +619,10 @@ do_load_request (GSimpleAsyncResult *result, GObject *object, GCancellable *canc
/* convert the encoded data into a useful object */
rb_debug ("converting %" G_GSIZE_FORMAT " bytes of file data", file_data_size);
- s = g_string_new_len (file_data, file_data_size);
+ s = g_slice_new0 (GString);
+ s->str = file_data;
+ s->len = file_data_size;
+ s->allocated_len = file_data_size;
g_value_init (&d, G_TYPE_GSTRING);
g_value_take_boxed (&d, s);
g_signal_emit (object, signals[LOAD], 0, &d, &req->data);
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index b7c1939..bfc1e9c 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -555,10 +555,13 @@ store_external_art_cb (RBExtDB *store, GValue *value, RBShell *shell)
return NULL;
}
- s = g_string_new_len (data, data_size);
+ s = g_slice_new0 (GString);
+ s->str = data;
+ s->len = data_size;
+ s->allocated_len = data_size;
v = g_new0 (GValue, 1);
g_value_init (v, G_TYPE_GSTRING);
- g_value_set_boxed (v, s);
+ g_value_take_boxed (v, s);
return v;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]