Browse Source

media player: add missing sanity check

Felix Paul Kühne 5 years ago
parent
commit
408eddbadf
1 changed files with 4 additions and 1 deletions
  1. 4 1
      Sources/VLCMediaPlayer.m

+ 4 - 1
Sources/VLCMediaPlayer.m

@@ -799,7 +799,10 @@ static void HandleMediaPlayerRecord(const libvlc_event_t * event, void * self)
 
 - (int)numberOfChaptersForTitle:(int)titleIndex
 {
-    return libvlc_media_player_get_chapter_count_for_title(_playerInstance, titleIndex);
+    if (titleIndex >= 0) {
+        return libvlc_media_player_get_chapter_count_for_title(_playerInstance, titleIndex);
+    }
+    return 0;
 }
 
 - (NSArray *)chapterDescriptionsOfTitle:(int)titleIndex