diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 7eb34728d0..ac98871d42 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -2091,7 +2091,14 @@ gst_buffer_add_meta (GstBuffer * buffer, const GstMetaInfo * info, /* create a new slice */ size = ITEM_SIZE (info); - item = g_slice_alloc (size); + /* We warn in gst_meta_register() about metas without + * init function but let's play safe here and prevent + * uninitialized memory + */ + if (!info->init_func) + item = g_slice_alloc0 (size); + else + item = g_slice_alloc (size); result = &item->meta; result->info = info; result->flags = GST_META_FLAG_NONE; diff --git a/gst/gstmeta.c b/gst/gstmeta.c index 1269c564d4..daa26ca18e 100644 --- a/gst/gstmeta.c +++ b/gst/gstmeta.c @@ -172,6 +172,10 @@ gst_meta_register (GType api, const gchar * impl, gsize size, g_return_val_if_fail (impl != NULL, NULL); g_return_val_if_fail (size != 0, NULL); + if (init_func == NULL) + g_critical ("Registering meta implementation '%s' without init function", + impl); + /* first try to register the implementation name. It's possible * that this fails because it was already registered. Don't warn, * glib did this for us already. */