basesrc: avoid trying to alloc enormous buffer

If a class extending basesrc doesn't set blocksize, basesrc
would try to allocate a (guint)-1 sized buffer, which is enormous
and likely would fail.

Avoid it and error out.
This commit is contained in:
Thiago Santos 2011-10-10 11:47:42 -03:00
parent 1cb205b30f
commit 59319194b8

View file

@ -1284,12 +1284,16 @@ gst_base_src_default_alloc (GstBaseSrc * src, guint64 offset,
if (priv->pool) {
ret = gst_buffer_pool_acquire_buffer (priv->pool, buffer, NULL);
} else {
} else if (size != -1) {
*buffer = gst_buffer_new_allocate (priv->allocator, size, priv->alignment);
if (G_UNLIKELY (*buffer == NULL))
goto alloc_failed;
ret = GST_FLOW_OK;
} else {
GST_WARNING_OBJECT (src, "Not trying to alloc %u bytes. Blocksize not set?",
size);
goto alloc_failed;
}
return ret;