From 765bb34641dce1cbc3fb8c7ba5ef30901f6b8305 Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Wed, 22 Jan 2020 15:14:05 -0600 Subject: [PATCH] UI: Don't allow resolutions too large Fixes a crash when entering large resolutions, and also works as a minor sanity check against bad resolution values. --- UI/window-basic-settings.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index f5db1f779..d53ba078a 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -95,6 +95,11 @@ struct CodecDesc { Q_DECLARE_METATYPE(FormatDesc) Q_DECLARE_METATYPE(CodecDesc) +static inline bool ResTooHigh(uint32_t cx, uint32_t cy) +{ + return cx > 16384 || cy > 16384; +} + /* parses "[width]x[height]", string, i.e. 1024x768 */ static bool ConvertResText(const char *res, uint32_t &cx, uint32_t &cy) { @@ -129,6 +134,11 @@ static bool ConvertResText(const char *res, uint32_t &cx, uint32_t &cy) if (lexer_getbasetoken(lex, &token, IGNORE_WHITESPACE)) return false; + if (ResTooHigh(cx, cy)) { + cx = cy = 0; + return false; + } + return true; }