Be extra cautious and only free XRRCrtcInfo if it's not nullptr in case the implementation doesn't handle it.

This commit is contained in:
Darío 2024-06-20 18:49:48 -03:00 committed by GitHub
parent e52aa9eea1
commit 7d8954e734
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -248,11 +248,14 @@ 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)) {
if (crtcInfo != nullptr) {
if (crtcInfo->mode != 0L) {
activeModeID = crtcInfo->mode;
}
XRRFreeCrtcInfo(crtcInfo);
}
}
if (activeModeID == 0L) {
fprintf(stderr, "Unable to find active mode through XRRGetScreenResources and XRRGetCrtcInfo.\n");