From ab5f2f4f5d129d502a33395ca77523d437dcf84a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 18 Nov 2009 09:10:37 +0000 Subject: [PATCH] Revert "structure: don't check type twice" This reverts commit f864187bf5fdfaf71f2e038949e403a42e6daf0e. Reverting this as it changes behaviour and the documentation is ambiguous about whether the caller must check the type first or not (call must check type vs. returns NULL if not a string). If GLib has been compiled with G_DISABLE_CHECKS then g_value_get_string() may return complete garbage even if the value does not contain a string. Better play it safe, esp. since the extra check is just an integer comparison. For fundamental types we could return values from the GValue structure directly if we really wanted to bypass the extra check. --- gst/gststructure.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gst/gststructure.c b/gst/gststructure.c index db4f774..cf8c785 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -1404,6 +1404,8 @@ gst_structure_get_string (const GstStructure * structure, if (field == NULL) return NULL; + if (!G_VALUE_HOLDS_STRING (&field->value)) + return NULL; return g_value_get_string (&field->value); } -- 2.7.4