message: Ensure that the "debug" field of error/warning/info messages is valid UTF-8
[platform/upstream/gstreamer.git] / gst / gstmessage.c
index 6c91f5e..a1d0d26 100644 (file)
@@ -415,6 +415,12 @@ gst_message_new_error_with_details (GstObject * src, GError * error,
   GstMessage *message;
   GstStructure *structure;
 
+  if (!g_utf8_validate (debug, -1, NULL)) {
+    debug = NULL;
+    g_warning ("Trying to set debug field of error message, but "
+        "string is not valid UTF-8. Please file a bug.");
+  }
+
   structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
       GST_QUARK (GERROR), G_TYPE_ERROR, error,
       GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
@@ -501,6 +507,12 @@ gst_message_new_warning_with_details (GstObject * src, GError * error,
   GstMessage *message;
   GstStructure *structure;
 
+  if (!g_utf8_validate (debug, -1, NULL)) {
+    debug = NULL;
+    g_warning ("Trying to set debug field of warning message, but "
+        "string is not valid UTF-8. Please file a bug.");
+  }
+
   structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
       GST_QUARK (GERROR), G_TYPE_ERROR, error,
       GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
@@ -585,6 +597,12 @@ gst_message_new_info_with_details (GstObject * src, GError * error,
   GstMessage *message;
   GstStructure *structure;
 
+  if (!g_utf8_validate (debug, -1, NULL)) {
+    debug = NULL;
+    g_warning ("Trying to set debug field of info message, but "
+        "string is not valid UTF-8. Please file a bug.");
+  }
+
   structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
       GST_QUARK (GERROR), G_TYPE_ERROR, error,
       GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
@@ -1007,10 +1025,7 @@ gst_message_new_element (GstObject * src, GstStructure * structure)
  * Create a new duration changed message. This message is posted by elements
  * that know the duration of a stream when the duration changes. This message
  * is received by bins and is used to calculate the total duration of a
- * pipeline. Elements may post a duration message with a duration of
- * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the 
- * cached duration should be discarded. The new duration can then be 
- * retrieved via a query.
+ * pipeline.
  *
  * Returns: (transfer full): The new duration-changed message.
  *
@@ -2171,7 +2186,7 @@ gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
  * to perform actions triggered by a state change.
  *
  * @code contains a well defined string describing the action.
- * @test should contain a user visible string detailing the current action.
+ * @text should contain a user visible string detailing the current action.
  *
  * Returns: (transfer full): The new qos message.
  */