From 81cc88326fc32bd05f43aafdda59a0c306ccf846 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 26 Jan 2009 17:59:37 -0800 Subject: [PATCH] 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). --- gst/typefind/gsttypefindfunctions.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index d352f6b..8994f6e 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -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; } -- 2.7.4