From f8e7ca6ea940e85a1dff0cd22f383456111ab784 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Tue, 20 Jul 2004 10:18:48 +0000 Subject: [PATCH] fix for 147929: [PATCH] running gst-register in non-utf8 locale can cause invalid registry Original commit message from CVS: fix for 147929: [PATCH] running gst-register in non-utf8 locale can cause invalid registry --- ChangeLog | 8 ++++++++ gst/gstelementfactory.c | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 439096e31b..b199f926ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-07-20 Thomas Vander Stichele + + patch by: Benjamin Otte + + * gst/gstelementfactory.c: (__gst_element_details_set): + fix for #147929: running gst-register in non-utf8 locale can cause + invalid registry + 2004-07-20 Thomas Vander Stichele patch by: Wim Taymans diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 64305e66a1..d6b0725608 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -134,14 +134,25 @@ __gst_element_details_clear (GstElementDetails * dp) dp->author = NULL; } +#define VALIDATE_SET(__dest, __src, __entry) \ +G_STMT_START { \ + if (g_utf8_validate (__src->__entry, -1, NULL)) { \ + __dest->__entry = g_strdup (__src->__entry); \ + } else { \ + g_warning ("Invalid UTF-8 in " G_STRINGIFY (__entry) ": %s", \ + __src->__entry); \ + __dest->__entry = g_strdup ("[ERROR: invalid UTF-8]"); \ + } \ +} G_STMT_END + void __gst_element_details_set (GstElementDetails * dest, const GstElementDetails * src) { - dest->longname = g_strdup (src->longname); - dest->klass = g_strdup (src->klass); - dest->description = g_strdup (src->description); - dest->author = g_strdup (src->author); + VALIDATE_SET (dest, src, longname); + VALIDATE_SET (dest, src, klass); + VALIDATE_SET (dest, src, description); + VALIDATE_SET (dest, src, author); } void @@ -151,6 +162,7 @@ __gst_element_details_copy (GstElementDetails * dest, __gst_element_details_clear (dest); __gst_element_details_set (dest, src); } + static void gst_element_factory_cleanup (GstElementFactory * factory) { -- 2.34.1