From 075def0f9771dd89503808e7d18f0569f7a76690 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 25 Feb 2015 08:26:19 +0100 Subject: 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 --- gst/gstvalue.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'gst') diff --git a/gst/gstvalue.h b/gst/gstvalue.h index de01abc55..2e15642e9 100644 --- a/gst/gstvalue.h +++ b/gst/gstvalue.h @@ -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 -- cgit v1.2.3