From 41e53034b0701c3f420f80398ed063be55faed12 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 5 Apr 2024 20:26:35 +0300 Subject: [PATCH] Do not attempt to create overlay if no screen is open. --- od-win32/direct3d.cpp | 6 +++++- od-win32/direct3d11.cpp | 6 +++++- od-win32/gdirender.cpp | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index 13d9db9b..1d672f9a 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -4257,10 +4257,14 @@ static bool xD3D_extoverlay(struct extoverlay *ext, int monid) return true; } - if (ext->width <= 0 || ext->height <= 0) + if (ext->width <= 0 || ext->height <= 0 || !d3d->d3ddev) { return false; + } ov = xcalloc(d3d9overlay, 1); + if (!ov) { + return false; + } s = createtext(d3d, ext->width, ext->height, D3DFMT_A8R8G8B8); if (!s) { xfree(ov); diff --git a/od-win32/direct3d11.cpp b/od-win32/direct3d11.cpp index eef8f36f..609cd1fe 100644 --- a/od-win32/direct3d11.cpp +++ b/od-win32/direct3d11.cpp @@ -5524,10 +5524,14 @@ static bool xD3D11_extoverlay(struct extoverlay *ext, int monid) return true; } - if (ext->width <= 0 || ext->height <= 0) + if (ext->width <= 0 || ext->height <= 0 || !d3d->m_device) { return false; + } ov = xcalloc(d3doverlay, 1); + if (!ov) { + return false; + } s = &ov->s; if (!allocsprite(d3d, s, ext->width, ext->height, true, false, false)) { diff --git a/od-win32/gdirender.cpp b/od-win32/gdirender.cpp index c4452d95..0997fd43 100644 --- a/od-win32/gdirender.cpp +++ b/od-win32/gdirender.cpp @@ -593,8 +593,9 @@ static bool gdi_extoverlay(struct extoverlay *ext, int monid) return true; } - if (ext->width <= 0 || ext->height <= 0 || !ext->data) + if (ext->width <= 0 || ext->height <= 0 || !ext->data || !gdi->hdc) { return false; + } ov = xcalloc(gdioverlay, 1); if (!ov) { -- 2.47.3