From 7cae57d3b792bcb5bf97abfe84cdedecc88f103e Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Tue, 1 Apr 2025 14:58:06 -0400 Subject: [PATCH] media-playback: Fix possible crash if frame width or height is zero If a frame has a width or height of zero, this value will make it into libobs/media-io/video-frame.c:video_frame_init and cause linesizes or heights to be zero, which will result in a bmalloc(0) call and OBS will crash. Instead of letting the call stack get that far, check the frame width and height here at the source, log an error, and return early if the frame width or height are zero. --- shared/media-playback/media-playback/media.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shared/media-playback/media-playback/media.c b/shared/media-playback/media-playback/media.c index ea2ee923e..c718ff9f3 100644 --- a/shared/media-playback/media-playback/media.c +++ b/shared/media-playback/media-playback/media.c @@ -382,6 +382,12 @@ void mp_media_next_video(mp_media_t *m, bool preload) enum video_range_type new_range; AVFrame *f = d->frame; + if (!f->width || !f->height) { + blog(LOG_ERROR, "MP: media frame width or height are zero ('%s': %" PRIu32 "x%" PRIu32 ")", m->path, + f->width, f->height); + return; + } + if (!preload) { if (!mp_media_can_play_frame(m, d)) return;