diff options
author | Rodeo <tdskywalker@gmail.com> | 2012-05-14 14:24:15 +0000 |
---|---|---|
committer | Rodeo <tdskywalker@gmail.com> | 2012-05-14 14:24:15 +0000 |
commit | ed6b38f56041302de83b6d94d8002336d58af1d3 (patch) | |
tree | aef57f9783681d520e318e09a5e569d307eaf31a | |
parent | b2176395d7ff74edf112126893ece8c9e4681ac4 (diff) |
Fix a crash when doing Foreign Audio Search with subtitle tracks that contain extradata (e.g. demuxed via libavformat).
Fix by John Stebbins.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4675 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/hb.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/libhb/hb.c b/libhb/hb.c index 1b3b1c8b0..d79939d86 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -1460,7 +1460,7 @@ void hb_add( hb_handle_t * h, hb_job_t * job ) hb_title_t * title, * title_copy; hb_chapter_t * chapter, * chapter_copy; hb_audio_t * audio; - hb_subtitle_t * subtitle, * subtitle_copy; + hb_subtitle_t * subtitle; hb_attachment_t * attachment; int i; char audio_lang[4]; @@ -1546,61 +1546,48 @@ void hb_add( hb_handle_t * h, hb_job_t * job ) */ memset( audio_lang, 0, sizeof( audio_lang ) ); - if ( job->indepth_scan ) { + if( job->indepth_scan ) + { - /* - * Find the first audio language that is being encoded - */ - for( i = 0; i < hb_list_count(job->list_audio); i++ ) + /* Find the first audio language that is being encoded, then add all the + * matching subtitles for that language. */ + for( i = 0; i < hb_list_count( job->list_audio ); i++ ) { if( ( audio = hb_list_item( job->list_audio, i ) ) ) { - strncpy(audio_lang, audio->config.lang.iso639_2, sizeof(audio_lang)); + strncpy( audio_lang, audio->config.lang.iso639_2, sizeof( audio_lang ) ); break; } } - } - - /* - * If doing a subtitle scan then add all the matching subtitles for this - * language. - */ - if ( job->indepth_scan ) - { - for( i=0; i < hb_list_count( title->list_subtitle ); i++ ) + for( i = 0; i < hb_list_count( title->list_subtitle ); i++ ) { subtitle = hb_list_item( title->list_subtitle, i ); if( strcmp( subtitle->iso639_2, audio_lang ) == 0 && hb_subtitle_can_force( subtitle->source ) ) { - /* - * Matched subtitle language with audio language, so + /* Matched subtitle language with audio language, so * add this to our list to scan. * * We will update the subtitle list on the second pass - * later after the first pass has completed. - */ - subtitle_copy = malloc( sizeof( hb_subtitle_t ) ); - memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) ); - hb_list_add( title_copy->list_subtitle, subtitle_copy ); + * later after the first pass has completed. */ + hb_list_add( title_copy->list_subtitle, hb_subtitle_copy( subtitle ) ); } } - } else { + } + else + { /* * Not doing a subtitle scan in this pass, but maybe we are in the * first pass? */ if( job->pass != 1 ) { - /* - * Copy all of them from the input job, to the title_copy/job_copy. - */ - for( i = 0; i < hb_list_count(job->list_subtitle); i++ ) { + /* Copy all subtitles from the input job to title_copy/job_copy. */ + for( i = 0; i < hb_list_count( job->list_subtitle ); i++ ) + { if( ( subtitle = hb_list_item( job->list_subtitle, i ) ) ) { - subtitle_copy = malloc( sizeof( hb_subtitle_t ) ); - memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) ); - hb_list_add( title_copy->list_subtitle, subtitle_copy ); + hb_list_add( title_copy->list_subtitle, hb_subtitle_copy( subtitle ) ); } } } |