From c4572afdb1d7e5060676e2e00ba8708c70474e93 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 27 Jun 2021 17:55:42 +0200 Subject: [PATCH] UWP: Add a missing bounds check from TextDrawerWin32::DrawStringBitmap Fixes a crash on switching tabs --- Common/Render/Text/draw_text_uwp.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Common/Render/Text/draw_text_uwp.cpp b/Common/Render/Text/draw_text_uwp.cpp index 6f5088619f..d12a41275f 100644 --- a/Common/Render/Text/draw_text_uwp.cpp +++ b/Common/Render/Text/draw_text_uwp.cpp @@ -359,6 +359,11 @@ void TextDrawerUWP::DrawStringBitmap(std::vector &bitmapData, TextStrin size.cx = metrics.width + 1; size.cy = metrics.height + 1; + if (size.cx > MAX_TEXT_WIDTH) + size.cx = MAX_TEXT_WIDTH; + if (size.cy > MAX_TEXT_HEIGHT) + size.cy = MAX_TEXT_HEIGHT; + // Prevent zero-sized textures, which can occur. Not worth to avoid // creating the texture altogether in this case. One example is a string // containing only '\r\n', see issue #10764.