From 3393b456e47f634cf571c647285611adf34a6d9f Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 16 Sep 2020 02:16:52 +0200 Subject: [PATCH] gstmeta: intern registered impl string Subsequent lookups in the hashtable are probably better done on memory we're confident is allocated to us :) It was easy to trigger invalid reads by calling gst_meta_register with dynamically allocated memory, freeing that memory, then calling gst_meta_get_info() Part-of: --- gst/gstmeta.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gst/gstmeta.c b/gst/gstmeta.c index c7c1f00290..ab36cefffd 100644 --- a/gst/gstmeta.c +++ b/gst/gstmeta.c @@ -198,7 +198,8 @@ gst_meta_register (GType api, const gchar * impl, gsize size, g_type_name (api), size); g_rw_lock_writer_lock (&lock); - g_hash_table_insert (metainfo, (gpointer) impl, (gpointer) info); + g_hash_table_insert (metainfo, (gpointer) g_intern_string (impl), + (gpointer) info); g_rw_lock_writer_unlock (&lock); return info;