From 7d8954e734717779b84889c413d4f5bffa8206f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo?= Date: Thu, 20 Jun 2024 18:49:48 -0300 Subject: [PATCH] Be extra cautious and only free XRRCrtcInfo if it's not nullptr in case the implementation doesn't handle it. --- src/hle/rt64_application_window.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hle/rt64_application_window.cpp b/src/hle/rt64_application_window.cpp index a407f53..377e8e8 100644 --- a/src/hle/rt64_application_window.cpp +++ b/src/hle/rt64_application_window.cpp @@ -248,10 +248,13 @@ namespace RT64 { RRMode activeModeID = 0; for (int i = 0; i < screenResources->ncrtc; ++i) { XRRCrtcInfo *crtcInfo = XRRGetCrtcInfo(windowHandle.display, screenResources, screenResources->crtcs[i]); - if ((crtcInfo != nullptr) && (crtcInfo->mode != 0L)) { - activeModeID = crtcInfo->mode; + if (crtcInfo != nullptr) { + if (crtcInfo->mode != 0L) { + activeModeID = crtcInfo->mode; + } + + XRRFreeCrtcInfo(crtcInfo); } - XRRFreeCrtcInfo(crtcInfo); } if (activeModeID == 0L) { @@ -366,4 +369,4 @@ namespace RT64 { #else static_assert(false && "Unimplemented"); #endif -}; \ No newline at end of file +};