dvdepay: Fix 'comparison of unsigned expression >= 0 is always true' compiler warning
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 6 Mar 2012 13:16:21 +0000 (14:16 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 6 Mar 2012 13:16:21 +0000 (14:16 +0100)
This was an actual bug as it could've caused reading from
invalid memory areas when the input is broken.

gst/rtp/gstrtpdvdepay.c

index 4098c39..43e6aa1 100644 (file)
@@ -336,12 +336,14 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in)
       GST_LOG_OBJECT (dvdepay, "got block at location %d", location);
     }
 
-    /* get the byte offset of the dif block */
-    offset = location * 80;
+    if (location != -1) {
+      /* get the byte offset of the dif block */
+      offset = location * 80;
 
-    /* And copy it in, provided the location is sane. */
-    if (offset >= 0 && offset <= dvdepay->frame_size - 80)
-      memcpy (GST_BUFFER_DATA (dvdepay->acc) + offset, payload, 80);
+      /* And copy it in, provided the location is sane. */
+      if (offset <= dvdepay->frame_size - 80)
+        memcpy (GST_BUFFER_DATA (dvdepay->acc) + offset, payload, 80);
+    }
 
     payload += 80;
     payload_len -= 80;