mirror of https://github.com/mpv-player/mpv
player: fix unchecked access for chapter metadata
It's possible that MPContext has a chapter list, but the demuxer doesn't. In this case, accesing the chapter-metadata property would lead to invalid accesses. (This fixes the out of bound access, but in theory, the returned data can still be incorrect, since MPContext chapters don't need to map directly to demuxer chapters.)
This commit is contained in:
parent
e565217f22
commit
6e2c29b786
|
@ -750,11 +750,9 @@ static int mp_property_chapter_metadata(m_option_t *prop, int action, void *arg,
|
||||||
{
|
{
|
||||||
struct demuxer *demuxer = mpctx->master_demuxer;
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
||||||
int chapter = get_current_chapter(mpctx);
|
int chapter = get_current_chapter(mpctx);
|
||||||
if (!demuxer || chapter < 0)
|
if (!demuxer || chapter < 0 || chapter >= demuxer->num_chapters)
|
||||||
return M_PROPERTY_UNAVAILABLE;
|
return M_PROPERTY_UNAVAILABLE;
|
||||||
|
|
||||||
assert(chapter < demuxer->num_chapters);
|
|
||||||
|
|
||||||
return tag_property(prop, action, arg, demuxer->chapters[chapter].metadata);
|
return tag_property(prop, action, arg, demuxer->chapters[chapter].metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue