File 741ac2167dda6b685ada5fd92b67c9e3aa5d685b.patch of Package Rhythmbox
From 741ac2167dda6b685ada5fd92b67c9e3aa5d685b Mon Sep 17 00:00:00 2001
From: Jonathan Matthew <jonathan@d14n.org>
Date: Mon, 6 Oct 2025 11:36:46 +1000
Subject: [PATCH] ext-db: use GBytes instead of GString to hold data buffers
GBytes is the more appropriate type to use, but it was too new when I
wrote this, but 14 years later it's fine.
Fixes: #2118
---
metadata/rb-ext-db.c | 21 ++++++++++-----------
shell/rb-shell.c | 11 ++++-------
2 files changed, 14 insertions(+), 18 deletions(-)
diff --git a/metadata/rb-ext-db.c b/metadata/rb-ext-db.c
index d7edc7b87..1f2b68ae5 100644
--- a/metadata/rb-ext-db.c
+++ b/metadata/rb-ext-db.c
@@ -654,17 +654,16 @@ do_load_request (GSimpleAsyncResult *result, GObject *object, GCancellable *canc
/* probably need to delete the item from the db */
} else {
- GString *s;
+ GBytes *b;
GValue d = G_VALUE_INIT;
/* convert the encoded data into a useful object */
rb_debug ("converting %" G_GSIZE_FORMAT " bytes of 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);
+
+ b = g_bytes_new_take (file_data, file_data_size);
+ g_value_init (&d, G_TYPE_BYTES);
+ g_value_take_boxed (&d, b);
+
req->data = NULL;
g_signal_emit (object, signals[LOAD], 0, &d, &req->data);
g_value_unset (&d);
@@ -987,12 +986,12 @@ do_store_request (GSimpleAsyncResult *result, GObject *object, GCancellable *can
g_clear_error (&error);
/* leave req->data alone so we fall into the failure branch? */
} else {
- GString *s;
+ GBytes *b;
rb_debug ("got %" G_GSIZE_FORMAT " bytes from uri %s", data_size, req->uri);
- s = g_string_new_len (data, data_size);
+ b = g_bytes_new_take (data, data_size);
req->data = g_new0 (GValue, 1);
- g_value_init (req->data, G_TYPE_GSTRING);
- g_value_take_boxed (req->data, s);
+ g_value_init (req->data, G_TYPE_BYTES);
+ g_value_take_boxed (req->data, b);
}
g_object_unref (f);
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index 334840f4f..63c45fc1b 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -403,7 +403,7 @@ store_external_art_cb (RBExtDB *store, GValue *value, RBShell *shell)
char *data;
gsize data_size;
GError *error = NULL;
- GString *s;
+ GBytes *b;
GValue *v;
if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF) == FALSE) {
@@ -433,13 +433,10 @@ store_external_art_cb (RBExtDB *store, GValue *value, RBShell *shell)
return NULL;
}
- s = g_slice_new0 (GString);
- s->str = data;
- s->len = data_size;
- s->allocated_len = data_size;
+ b = g_bytes_new_take (data, data_size);
v = g_new0 (GValue, 1);
- g_value_init (v, G_TYPE_GSTRING);
- g_value_take_boxed (v, s);
+ g_value_init (v, G_TYPE_BYTES);
+ g_value_take_boxed (v, b);
return v;
}
--
GitLab