Ensure we have sufficient data when using data scan contexts.

Fixes crashes typefinding things that look like they might contain AAC
data (but probably aren't actually AAC).
This commit is contained in:
Michael Smith 2009-01-26 17:59:37 -08:00
parent 9fbf201167
commit 81cc88326f

View file

@ -67,14 +67,15 @@ data_scan_ctx_ensure_data (GstTypeFind * tf, DataScanCtx * c, gint min_len)
{
const guint8 *data;
guint64 len;
guint chunk_len = MAX (DATA_SCAN_CTX_CHUNK_SIZE, min_len);
if (G_LIKELY (c->size >= min_len))
return TRUE;
data = gst_type_find_peek (tf, c->offset, DATA_SCAN_CTX_CHUNK_SIZE);
data = gst_type_find_peek (tf, c->offset, chunk_len);
if (G_LIKELY (data != NULL)) {
c->data = data;
c->size = DATA_SCAN_CTX_CHUNK_SIZE;
c->size = chunk_len;
return TRUE;
}
@ -83,7 +84,7 @@ data_scan_ctx_ensure_data (GstTypeFind * tf, DataScanCtx * c, gint min_len)
* of the stream and not have as much data available as we'd like) */
len = gst_type_find_get_length (tf);
if (len > 0) {
len = CLAMP (len - c->offset, min_len, DATA_SCAN_CTX_CHUNK_SIZE);
len = CLAMP (len - c->offset, min_len, chunk_len);
} else {
len = min_len;
}