DisplayManager - fix crashes when setting absurdly large padding values (fixes #3321)

This commit is contained in:
zeromus 2022-07-22 16:04:07 -04:00
parent 6eafdf7156
commit 3b181ba6e4
1 changed files with 14 additions and 0 deletions

View File

@ -317,6 +317,11 @@ namespace BizHawk.Client.Common
Size size = chainInSize;
size.Width += padding.Left + padding.Right;
size.Height += padding.Top + padding.Bottom;
//in case the user requested so much padding that the dimensions are now negative, just turn it to something small
if (size.Width < 1) size.Width = 1;
if (size.Height < 1) size.Height = 1;
FinalPresentation fPadding = new FinalPresentation(size);
chain.AddFilter(fPadding, "padding");
fPadding.GuiRenderer = _renderer;
@ -619,6 +624,11 @@ namespace BizHawk.Client.Common
bufferWidth += padding.Horizontal;
bufferHeight += padding.Vertical;
//in case the user requested so much padding that the dimensions are now negative, just turn it to something small.
if (virtualWidth < 1) virtualWidth = 1;
if (virtualHeight < 1) virtualHeight = 1;
if (bufferWidth < 1) bufferWidth = 1;
if (bufferHeight < 1) bufferHeight = 1;
// old stuff
var fvp = new FakeVideoProvider
@ -833,6 +843,10 @@ namespace BizHawk.Client.Common
vw += padding.Horizontal;
vh += padding.Vertical;
//in case the user requested so much padding that the dimensions are now negative, just turn it to something small.
if (vw < 1) vw = 1;
if (vh < 1) vh = 1;
BitmapBuffer bb = null;
Texture2d videoTexture = null;
if (!simulate)