Quellcode durchsuchen

Merge pull request #2345 from cg2121/fix-res-crash

UI: Fix crash when entering large resolutions
Jim vor 6 Jahren
Ursprung
Commit
818e3a364e
1 geänderte Dateien mit 10 neuen und 0 gelöschten Zeilen
  1. 10 0
      UI/window-basic-settings.cpp

+ 10 - 0
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;
 }