فهرست منبع

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.
Ryan Foster 5 ماه پیش
والد
کامیت
c86de0587a
1فایلهای تغییر یافته به همراه3 افزوده شده و 0 حذف شده
  1. 3 0
      plugins/win-capture/duplicator-monitor-capture.c

+ 3 - 0
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) ==