From c86de0587a6c8f7b54f122f76631a86e7fe1c3ac Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Thu, 1 May 2025 15:06:14 -0400 Subject: [PATCH] win-capture: Fix crash if no display is available If no displays are available, numPath or numMode can be 0, which will result in a bmalloc(0) call and OBS will crash. --- plugins/win-capture/duplicator-monitor-capture.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/win-capture/duplicator-monitor-capture.c b/plugins/win-capture/duplicator-monitor-capture.c index fd72727df..ee6cef014 100644 --- a/plugins/win-capture/duplicator-monitor-capture.c +++ b/plugins/win-capture/duplicator-monitor-capture.c @@ -130,6 +130,9 @@ static bool GetMonitorTarget(LPCWSTR device, DISPLAYCONFIG_TARGET_DEVICE_NAME *t UINT32 numPath, numMode; if (GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &numPath, &numMode) == ERROR_SUCCESS) { + if (!numPath || !numMode) { + return false; + } DISPLAYCONFIG_PATH_INFO *paths = bmalloc(numPath * sizeof(DISPLAYCONFIG_PATH_INFO)); DISPLAYCONFIG_MODE_INFO *modes = bmalloc(numMode * sizeof(DISPLAYCONFIG_MODE_INFO)); if (QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &numPath, paths, &numMode, modes, NULL) ==