From 403fc86c1138821fac375a2ac850ac787969e2c8 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Fri, 8 Oct 2021 01:22:38 -0400 Subject: vic: Avoid memory corruption when multiple streams with different dimensions are decoded This is a work around to avoid buffer overflow errors until multi channel/multi stream decoding is supported. --- src/video_core/command_classes/vic.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/video_core/command_classes/vic.cpp') diff --git a/src/video_core/command_classes/vic.cpp b/src/video_core/command_classes/vic.cpp index 3f2712a8d..51f739801 100644 --- a/src/video_core/command_classes/vic.cpp +++ b/src/video_core/command_classes/vic.cpp @@ -85,6 +85,15 @@ void Vic::Execute() { if (!frame) { return; } + const u64 surface_width = config.surface_width_minus1 + 1; + const u64 surface_height = config.surface_height_minus1 + 1; + if (static_cast(frame->width) != surface_width || + static_cast(frame->height) != surface_height) { + // TODO: Properly support multiple video streams with differing frame dimensions + LOG_WARNING(Debug, "Frame dimensions {}x{} do not match expected surface dimensions {}x{}", + frame->width, frame->height, surface_width, surface_height); + return; + } switch (config.pixel_format) { case VideoPixelFormat::RGBA8: case VideoPixelFormat::BGRA8: -- cgit v1.2.3