gdp: fix failure to deserialize event packets with empty payload (only ev...
authorThomas Vander Stichele <thomas@apestaart.org>
Thu, 13 Jul 2006 14:02:16 +0000 (14:02 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sun, 25 Dec 2011 22:49:58 +0000 (22:49 +0000)
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_event_from_packet_1_0):
Fixes #347337: failure to deserialize event packets with
empty payload (only event type)

gst/gdp/dataprotocol.c

index 887b2ee..dd290cc 100644 (file)
@@ -659,15 +659,16 @@ gst_dp_event_from_packet_1_0 (guint header_length, const guint8 * header,
 {
   GstEvent *event = NULL;
   GstEventType type;
-  gchar *string;
-  GstStructure *s;
+  gchar *string = NULL;
+  GstStructure *s = NULL;
 
   type = GST_DP_HEADER_PAYLOAD_TYPE (header) - GST_DP_PAYLOAD_EVENT_NONE;
-  string = g_strndup ((gchar *) payload, GST_DP_HEADER_PAYLOAD_LENGTH (header));
-  s = gst_structure_from_string (string, NULL);
-  g_free (string);
-  if (!s)
-    return NULL;
+  if (payload) {
+    string =
+        g_strndup ((gchar *) payload, GST_DP_HEADER_PAYLOAD_LENGTH (header));
+    s = gst_structure_from_string (string, NULL);
+    g_free (string);
+  }
   event = gst_event_new_custom (type, s);
   return event;
 }