MacGui: check if a chapter is not NULL before reading its duration

This commit is contained in:
Damiano Galassi 2025-04-23 11:46:11 +02:00
parent 20c354333f
commit 158f694e43
No known key found for this signature in database
GPG Key ID: 5452E231DFDBCA11

View File

@ -119,14 +119,16 @@ NSString *HBRangeChangedNotification = @"HBRangeChangedNotification";
{
if (self.type == HBRangeTypeChapters)
{
hb_title_t *title = self.title.hb_title;
hb_chapter_t *chapter;
int64_t duration = 0;
hb_title_t *title = self.title.hb_title;
for (int i = self.chapterStart; i <= self.chapterStop; i++ )
{
chapter = (hb_chapter_t *) hb_list_item(title->list_chapter, i);
duration += chapter->duration;
hb_chapter_t *chapter = (hb_chapter_t *)hb_list_item(title->list_chapter, i);
if (chapter)
{
duration += chapter->duration;
}
}
duration /= 90000; // pts -> seconds