From a001e1d5b6d546c2ac9527f0dd458b6d30f47688 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Thu, 7 Jul 2011 17:25:38 +0000 Subject: [PATCH] libhb: fix a stack corruption crash when scanning some BDs was overrunning the end of a stack based array when there were more than 32 clips in a BD title. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4086 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/bd.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/libhb/bd.c b/libhb/bd.c index 9231436f6..cd33479dd 100644 --- a/libhb/bd.c +++ b/libhb/bd.c @@ -312,28 +312,22 @@ hb_title_t * hb_bd_title_scan( hb_bd_t * d, int tt, uint64_t min_duration ) // So find the clip that has the most other clips with the // matching audio. // Max primary BD audios is 32 - uint8_t counts[32] = {0,}; - uint8_t matches[32] = {0,}; + int matches; int most_audio = 0; int audio_clip_index = 0; for ( ii = 0; ii < ti->clip_count; ii++ ) { - if ( matches[ii] ) continue; + matches = 0; for ( jj = 0; jj < ti->clip_count; jj++ ) { - if ( matches[jj] ) continue; if ( bd_audio_equal( &ti->clips[ii], &ti->clips[jj] ) ) { - matches[ii] = matches[jj] = 1; - counts[ii]++; + matches++; } } - } - for ( ii = 0; ii < ti->clip_count; ii++ ) - { - if ( most_audio < counts[ii] ) + if ( matches > most_audio ) { - most_audio = counts[ii]; + most_audio = matches; audio_clip_index = ii; } } -- 2.40.0