mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
gstvalue: Make sure GST_FOURCC_ARGS produces printable characters
Some systems will crash if we use non-printable characters in print/debug statements. Make sure that GST_FOURCC_ARGS never does that https://bugzilla.gnome.org/show_bug.cgi?id=745144
This commit is contained in:
parent
4245658d28
commit
075def0f97
2 changed files with 25 additions and 5 deletions
|
@ -80,12 +80,14 @@ G_BEGIN_DECLS
|
|||
* Can be used together with #GST_FOURCC_FORMAT to properly output a
|
||||
* #guint32 fourcc value in a printf()-style text message.
|
||||
*/
|
||||
#define GST_FOURCC_ARGS(fourcc) \
|
||||
((gchar) ((fourcc) &0xff)), \
|
||||
((gchar) (((fourcc)>>8 )&0xff)), \
|
||||
((gchar) (((fourcc)>>16)&0xff)), \
|
||||
((gchar) (((fourcc)>>24)&0xff))
|
||||
|
||||
#define __GST_PRINT_CHAR(c) \
|
||||
g_ascii_isprint(c) ? (c) : '.'
|
||||
#define GST_FOURCC_ARGS(fourcc) \
|
||||
__GST_PRINT_CHAR((fourcc) & 0xff), \
|
||||
__GST_PRINT_CHAR(((fourcc) >> 8) & 0xff), \
|
||||
__GST_PRINT_CHAR(((fourcc) >> 16) & 0xff), \
|
||||
__GST_PRINT_CHAR(((fourcc) >> 24) & 0xff)
|
||||
/**
|
||||
* GST_VALUE_HOLDS_INT_RANGE:
|
||||
* @x: the #GValue to check
|
||||
|
|
|
@ -332,6 +332,23 @@ GST_START_TEST (info_register_same_debug_category_twice)
|
|||
GST_END_TEST;
|
||||
#endif
|
||||
|
||||
GST_START_TEST (info_fourcc)
|
||||
{
|
||||
gchar *res;
|
||||
const gchar *cmp;
|
||||
|
||||
cmp = "abcd";
|
||||
res = g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (0x64636261));
|
||||
fail_unless_equals_string (res, cmp);
|
||||
g_free (res);
|
||||
|
||||
cmp = ".bcd";
|
||||
res = g_strdup_printf ("%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (0x646362a9));
|
||||
fail_unless_equals_string (res, cmp);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
gst_info_suite (void)
|
||||
{
|
||||
|
@ -341,6 +358,7 @@ gst_info_suite (void)
|
|||
tcase_set_timeout (tc_chain, 30);
|
||||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, info_fourcc);
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
tcase_add_test (tc_chain, info_segment_format_printf_extension);
|
||||
tcase_add_test (tc_chain, info_ptr_format_printf_extension);
|
||||
|
|
Loading…
Reference in a new issue