device-monitor: Fix criticals when dumping non-string values

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9494>
This commit is contained in:
Nirbheek Chauhan 2025-08-05 12:40:21 +01:00 committed by GStreamer Marge Bot
parent fe760ca71d
commit fe2db9df3d

View File

@ -80,12 +80,20 @@ do_shell_quote (const char *s)
static char *
value_to_string (const GValue * v)
{
const char *d, *s = g_value_get_string (v);
const char *d, *s = NULL;
char *ret, *ser = NULL;
gboolean need_quote = FALSE;
gboolean need_serialize = FALSE;
if (G_VALUE_HOLDS_STRING (v)) {
s = g_value_get_string (v);
need_serialize = !g_str_is_ascii (s);
} else {
need_serialize = TRUE;
}
/* Don't mess around if the value is weird */
if (!G_VALUE_HOLDS_STRING (v) || !g_str_is_ascii (s)) {
if (need_serialize) {
ser = gst_value_serialize (v);
ret = do_shell_quote (ser);
g_free (ser);