rtcpbuffer: fix function guards with side effects
authorTim-Philipp Müller <tim@centricular.com>
Sun, 30 Dec 2018 17:26:04 +0000 (17:26 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Sun, 30 Dec 2018 17:28:38 +0000 (17:28 +0000)
Code in g_return_*() must not have side effects, as it
might be compiled out if -DG_DISABLE_CHECKS is used, in
which case we would read garbage off the stack.

gst-libs/gst/rtp/gstrtcpbuffer.c

index 25201d6..eff0f00 100644 (file)
@@ -2822,8 +2822,9 @@ gst_rtcp_packet_xr_get_rle_nth_chunk (GstRTCPPacket * packet,
   guint32 chunk_count;
   guint8 *data;
 
-  g_return_val_if_fail (gst_rtcp_packet_xr_get_rle_info (packet, NULL, NULL,
-          NULL, NULL, &chunk_count), FALSE);
+  if (!gst_rtcp_packet_xr_get_rle_info (packet, NULL, NULL, NULL, NULL,
+          &chunk_count))
+    g_return_val_if_reached (FALSE);
 
   if (nth >= chunk_count)
     return FALSE;
@@ -2917,8 +2918,9 @@ gst_rtcp_packet_xr_get_prt_by_seq (GstRTCPPacket * packet,
   guint16 begin_seq, end_seq;
   guint8 *data;
 
-  g_return_val_if_fail (gst_rtcp_packet_xr_get_prt_info (packet, NULL, NULL,
-          &begin_seq, &end_seq), FALSE);
+  if (!gst_rtcp_packet_xr_get_prt_info (packet, NULL, NULL, &begin_seq,
+          &end_seq))
+    g_return_val_if_reached (FALSE);
 
   if (seq >= end_seq || seq < begin_seq)
     return FALSE;