pad: Add a guard against getrange functions not filling a caller-provided buffer
authorSebastian Dröge <sebastian@centricular.com>
Thu, 2 Apr 2020 10:45:48 +0000 (13:45 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 2 Apr 2020 10:47:37 +0000 (13:47 +0300)
It's a programming error to not do so and would cause all kinds of
problems in the caller that assumed its own buffer to have been filled.

gst/gstpad.c

index 456bf37..0d43108 100644 (file)
@@ -4878,6 +4878,10 @@ probed_data:
 
   GST_PAD_STREAM_UNLOCK (pad);
 
+  /* If the caller provided a buffer it must be filled by the getrange
+   * function instead of it returning a new buffer */
+  g_return_val_if_fail (!*buffer || res_buf == *buffer, GST_FLOW_ERROR);
+
   *buffer = res_buf;
 
   return ret;