]> granicus.if.org Git - handbrake/commitdiff
Don't crash when the user specifies audio tracks that don't exist from the HandBrakeCLI
authoreddyg <eddyg.hb@myreflection.org>
Mon, 18 Aug 2008 04:25:18 +0000 (04:25 +0000)
committereddyg <eddyg.hb@myreflection.org>
Mon, 18 Aug 2008 04:25:18 +0000 (04:25 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1640 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.c
test/test.c

index c8cc8dddc810b82c24f2b50f018c94b20285f4fe..f0ad9e4a279433610da9ca2bdc5c607bfc2fdc26 100644 (file)
@@ -667,8 +667,13 @@ void hb_filter_close( hb_filter_object_t ** _f )
  *********************************************************************/
 hb_audio_t *hb_audio_copy(const hb_audio_t *src)
 {
-    hb_audio_t *audio = calloc(1, sizeof(*audio));
-    memcpy(audio, src, sizeof(*audio));
+    hb_audio_t *audio = NULL;
+
+    if( src )
+    {
+        audio = calloc(1, sizeof(*audio));
+        memcpy(audio, src, sizeof(*audio));
+    }
     return audio;
 }
 
index 3fd9d0e6258b9c713ac3cd03e2bf90e6c65655cf..01cd715f88801f1612d27618f45d627bc4ed5a7c 100644 (file)
@@ -965,7 +965,12 @@ static int HandleEvents( hb_handle_t * h )
                 }
                 else
                 {
-                    hb_audio_add( job, audio );
+                    if( hb_audio_add( job, audio ) == 0 )
+                    {
+                        fprintf(stderr, "ERROR: Invalid audio input track '%u', skipping.\n", 
+                                audio->in.track + 1 );
+                        num_audio_tracks--;
+                    }
                 }
                 hb_list_rem(audios, audio);
                 if( audio != NULL)