[vlc-commits] [Git][videolan/vlc][master] lib/media_player: fix invalid title index
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Sun Jul 31 15:38:59 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
e40112f1 by Thomas Guillem at 2022-07-31T15:00:10+00:00
lib/media_player: fix invalid title index
A i_chapters_of_title of -1 mean the current title, so fetch it in that
case.
It fixes a crash while attempting to reach the title array at -1.
- - - - -
1 changed file:
- lib/media_player.c
Changes:
=====================================
lib/media_player.c
=====================================
@@ -1496,11 +1496,26 @@ 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)
- goto end;
+
+ ssize_t title_idx;
+ if (i_chapters_of_title < 0)
+ {
+ title_idx = vlc_player_GetSelectedTitleIdx(player);
+ if (title_idx == -1)
+ goto end;
+
+ assert((size_t)title_idx < titles_count);
+ }
+ else
+ {
+ title_idx = i_chapters_of_title;
+
+ if ((size_t) title_idx >= titles_count)
+ goto end;
+ }
const struct vlc_player_title *title =
- vlc_player_title_list_GetAt(titles, i_chapters_of_title);
+ vlc_player_title_list_GetAt(titles, title_idx);
assert(title);
size_t i_chapter_count = title->chapter_count;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e40112f175356227d7baa484c80e9c679cc9f110
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e40112f175356227d7baa484c80e9c679cc9f110
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list