[vlc-devel] [PATCH] libvlc: fix title count conditional for chapter descriptions

Mark Lee mark.lee at capricasoftware.co.uk
Thu Apr 8 17:30:53 UTC 2021


Chapter descriptions were not being returned for valid title
indices.

The conditional check would return true (and therefore abort the
method) when the requested title index was less than the title
count, i.e. when it was valid.
---
 lib/media_player.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/media_player.c b/lib/media_player.c
index 9341c49a68..61c354517f 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1364,7 +1364,7 @@ int libvlc_media_player_get_chapter_count_for_title(
         goto end;
 
     size_t titles_count = vlc_player_title_list_GetCount(titles);
-    if (idx < titles_count)
+    if (idx >= titles_count)
        goto end;
 
     const struct vlc_player_title *title =
@@ -1489,7 +1489,7 @@ int libvlc_media_player_get_full_chapter_descriptions( libvlc_media_player_t *p_
         goto end;
 
     size_t titles_count = vlc_player_title_list_GetCount(titles);
-    if (i_chapters_of_title < (int) titles_count)
+    if (i_chapters_of_title >= (int) titles_count)
        goto end;
 
     const struct vlc_player_title *title =
-- 
2.25.1



More information about the vlc-devel mailing list