mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-24 10:14:13 -05:00
deps/media-playback: Check if frame can be played before using it
It's possible that frame_ready is false when this function is called, which implies that the mp_decode frame field is not valid. However we dereference the frame by counting the number of audio channels before checking the value of frame_ready, causing a crash.
This commit is contained in:
+4
-3
@@ -356,15 +356,16 @@ void mp_media_next_audio(mp_media_t *m)
|
||||
struct obs_source_audio audio = {0};
|
||||
AVFrame *f = d->frame;
|
||||
int channels;
|
||||
|
||||
if (!mp_media_can_play_frame(m, d))
|
||||
return;
|
||||
|
||||
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59, 19, 100)
|
||||
channels = f->channels;
|
||||
#else
|
||||
channels = f->ch_layout.nb_channels;
|
||||
#endif
|
||||
|
||||
if (!mp_media_can_play_frame(m, d))
|
||||
return;
|
||||
|
||||
d->frame_ready = false;
|
||||
if (!m->a_cb)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user