From 2e7d196f8bf2c13c471d5b91145c6b14b33f0692 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 4 Apr 2018 11:46:14 +0300 Subject: [PATCH] Fixed crash when vid_setmode CCMD is used from command line It's impossible to validate video mode at such early stage of initialization Added sanity check for mode's width and height as well https://forum.zdoom.org/viewtopic.php?t=59990 --- src/v_video.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/v_video.cpp b/src/v_video.cpp index 761c805d7c..1ac815bc5f 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1454,7 +1454,6 @@ bool IVideo::SetResolution (int width, int height, int bits) CCMD (vid_setmode) { - bool goodmode = false; int width = 0, height = SCREENHEIGHT; int bits = DisplayBits; @@ -1471,13 +1470,8 @@ CCMD (vid_setmode) } } - if (width && I_CheckResolution (width, height, bits)) - { - goodmode = true; - } - - if (!fullscreen) - goodmode = true; + const bool goodmode = (width > 0 && height > 0) + && (!fullscreen || (Video != nullptr && I_CheckResolution(width, height, bits))); if (goodmode) {