From a8e901e754472539d9ce1257ae1758e7e96a31b8 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Fri, 16 Jun 2023 16:09:34 -0600 Subject: [PATCH] Assert that a video mode exists before trying to use it This converts a segfault into a more predictable failure, at least in debug builds. --- src/SFML/Window/Window.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 1ca04545..d28fd0e6 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -34,6 +34,8 @@ #include +#include + namespace sf { @@ -90,6 +92,7 @@ void Window::create(VideoMode mode, const String& title, std::uint32_t style, co if (!mode.isValid()) { err() << "The requested video mode is not available, switching to a valid mode" << std::endl; + assert(!VideoMode::getFullscreenModes().empty() && "No video modes available"); mode = VideoMode::getFullscreenModes()[0]; }