From: Rodeo Date: Mon, 14 May 2012 14:34:25 +0000 (+0000) Subject: Bugfix branch: merge fix for Foreign Audio Search crash. X-Git-Tag: 0.9.6.1~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53217a5d83e6ca1b37bb2f82879f2bde5efe13d7;p=handbrake Bugfix branch: merge fix for Foreign Audio Search crash. git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/0.9.x@4676 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/libhb/hb.c b/libhb/hb.c index 31456784f..136a4f640 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -1343,7 +1343,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]; @@ -1429,61 +1429,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 && subtitle->source == VOBSUB ) { - /* - * 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 ) ); } } }