mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
registry: move utf-8 validation to registry saving time
Instead of checking for valid utf-8 element-details every time we create elements (from plugin-init or registry), do it before we save the registry. Fixes #656193.
This commit is contained in:
parent
e77098101f
commit
20618b4c28
2 changed files with 33 additions and 27 deletions
|
@ -35,33 +35,21 @@ __gst_element_details_clear (GstElementDetails * dp)
|
|||
memset (dp, 0, sizeof (GstElementDetails));
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
static inline void
|
||||
__gst_element_details_set (GstElementDetails * dest,
|
||||
const GstElementDetails * src)
|
||||
{
|
||||
VALIDATE_SET (dest, src, longname);
|
||||
VALIDATE_SET (dest, src, klass);
|
||||
VALIDATE_SET (dest, src, description);
|
||||
VALIDATE_SET (dest, src, author);
|
||||
}
|
||||
|
||||
static inline void
|
||||
__gst_element_details_copy (GstElementDetails * dest,
|
||||
const GstElementDetails * src)
|
||||
{
|
||||
__gst_element_details_clear (dest);
|
||||
__gst_element_details_set (dest, src);
|
||||
g_free (dest->longname);
|
||||
dest->longname = g_strdup (src->longname);
|
||||
|
||||
g_free (dest->klass);
|
||||
dest->klass = g_strdup (src->klass);
|
||||
|
||||
g_free (dest->description);
|
||||
dest->description = g_strdup (src->description);
|
||||
|
||||
g_free (dest->author);
|
||||
dest->author = g_strdup (src->author);
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -207,6 +207,16 @@ gst_registry_chunks_save_pad_template (GList ** list,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#define VALIDATE_UTF8(__details, __entry) \
|
||||
G_STMT_START { \
|
||||
if (!g_utf8_validate (__details->__entry, -1, NULL)) { \
|
||||
g_warning ("Invalid UTF-8 in " G_STRINGIFY (__entry) ": %s", \
|
||||
__details->__entry); \
|
||||
g_free (__details->__entry); \
|
||||
__details->__entry = g_strdup ("[ERROR: invalid UTF-8]"); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
/*
|
||||
* gst_registry_chunks_save_feature:
|
||||
*
|
||||
|
@ -230,6 +240,14 @@ gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
|
|||
if (GST_IS_ELEMENT_FACTORY (feature)) {
|
||||
GstRegistryChunkElementFactory *ef;
|
||||
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
|
||||
GstElementDetails *details = &factory->details;
|
||||
|
||||
/* do the utf-8 validation of the element factory details here to avoid
|
||||
* doing it every time we load */
|
||||
VALIDATE_UTF8 (details, longname);
|
||||
VALIDATE_UTF8 (details, klass);
|
||||
VALIDATE_UTF8 (details, description);
|
||||
VALIDATE_UTF8 (details, author);
|
||||
|
||||
/* Initialize with zeroes because of struct padding and
|
||||
* valgrind complaining about copying unitialized memory
|
||||
|
@ -285,10 +303,10 @@ gst_registry_chunks_save_feature (GList ** list, GstPluginFeature * feature)
|
|||
}
|
||||
|
||||
/* pack element factory strings */
|
||||
gst_registry_chunks_save_const_string (list, factory->details.author);
|
||||
gst_registry_chunks_save_const_string (list, factory->details.description);
|
||||
gst_registry_chunks_save_const_string (list, factory->details.klass);
|
||||
gst_registry_chunks_save_const_string (list, factory->details.longname);
|
||||
gst_registry_chunks_save_const_string (list, details->author);
|
||||
gst_registry_chunks_save_const_string (list, details->description);
|
||||
gst_registry_chunks_save_const_string (list, details->klass);
|
||||
gst_registry_chunks_save_const_string (list, details->longname);
|
||||
if (factory->meta_data) {
|
||||
gst_registry_chunks_save_string (list,
|
||||
gst_structure_to_string (factory->meta_data));
|
||||
|
|
Loading…
Reference in a new issue