Hi,

during enumerating self->audio_codec or other arrays that has limit MAX_AUDIO_STREAMS it is possible to access out of index range. attached patch fix that behavior.

NB
i noticed that current value of MAX_AUDIO_STREAMS is 10. that mean that it will be unable to access audio track with index 11 or more. so i would suggest to increase MAX_AUDIO_STREAMS value up to 32 or bigger

--
________________________________________
Maksym Veremeyenko
>From b6fd64bbf0b0def1a0cb7092c07b2d5351a51be5 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <ve...@m1stereo.tv>
Date: Fri, 28 Sep 2012 16:24:05 +0200
Subject: [PATCH] fix array index out of range

---
 src/modules/avformat/producer_avformat.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c
index 2419238..48150ed 100644
--- a/src/modules/avformat/producer_avformat.c
+++ b/src/modules/avformat/producer_avformat.c
@@ -2272,7 +2272,7 @@ static int producer_get_audio( mlt_frame frame, void **buffer, mlt_audio_format
 	if ( self->audio_index == INT_MAX )
 	{
 		index = 0;
-		index_max = context->nb_streams;
+		index_max = FFMIN( MAX_AUDIO_STREAMS, context->nb_streams );
 		*channels = self->total_channels;
 		*samples = *samples * FFMAX( self->max_frequency, *frequency ) / *frequency;
 		*frequency = FFMAX( self->max_frequency, *frequency );
@@ -2351,7 +2351,7 @@ static int producer_get_audio( mlt_frame frame, void **buffer, mlt_audio_format
 			{
 				// Check if there is enough audio for all streams
 				got_audio = 1;
-				for ( index = 0; got_audio && index < context->nb_streams; index++ )
+				for ( index = 0; got_audio && index < index_max; index++ )
 					if ( ( self->audio_codec[ index ] && self->audio_used[ index ] < *samples ) || ignore[ index ] )
 						got_audio = 0;
 				if ( got_audio )
-- 
1.7.7.6

------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to