From 6321432d971bcf291247dc1c7f70aeb4d091c2b1 Mon Sep 17 00:00:00 2001 From: penev92 Date: Mon, 13 Feb 2023 23:35:22 +0200 Subject: [PATCH] Fix crash caused by VideoPlayerWidget.DrawOverlay Somehow this would divide by 0 on the next line, not crashing but resulting in an integer overflow on `overlayHeight`, which would crash when trying to render. --- OpenRA.Mods.Common/Widgets/VideoPlayerWidget.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OpenRA.Mods.Common/Widgets/VideoPlayerWidget.cs b/OpenRA.Mods.Common/Widgets/VideoPlayerWidget.cs index 7f8577194c..fb769bcb10 100644 --- a/OpenRA.Mods.Common/Widgets/VideoPlayerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/VideoPlayerWidget.cs @@ -144,6 +144,13 @@ namespace OpenRA.Mods.Common.Widgets var videoScale = Math.Min((float)RenderBounds.Width / video.Width, RenderBounds.Height / (video.Height * AspectRatio)); var halfRowHeight = (int)(videoScale * scale / 2 + 0.5f); + // If the video is "too tightly packed" into the player and there is no room for drawing an overlay disable it. + if (halfRowHeight == 0) + { + DrawOverlay = false; + return; + } + // The overlay can be minimally stored in a 1px column which is stretched to cover the full screen var overlayHeight = (int)(RenderBounds.Height * scale / halfRowHeight); var overlaySheetSize = new Size(1, Exts.NextPowerOf2(overlayHeight));