소스 검색

win-capture: Check return values on Windows API functions

Richard Stanway 10 년 전
부모
커밋
7630946874
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 4
      plugins/win-capture/window-helpers.c

+ 4 - 4
plugins/win-capture/window-helpers.c

@@ -114,8 +114,8 @@ static void get_window_title(struct dstr *name, HWND hwnd)
 		return;
 		return;
 
 
 	temp = malloc(sizeof(wchar_t) * (len+1));
 	temp = malloc(sizeof(wchar_t) * (len+1));
-	GetWindowTextW(hwnd, temp, len+1);
-	dstr_from_wcs(name, temp);
+	if (GetWindowTextW(hwnd, temp, len+1))
+		dstr_from_wcs(name, temp);
 	free(temp);
 	free(temp);
 }
 }
 
 
@@ -124,8 +124,8 @@ static void get_window_class(struct dstr *class, HWND hwnd)
 	wchar_t temp[256];
 	wchar_t temp[256];
 
 
 	temp[0] = 0;
 	temp[0] = 0;
-	GetClassNameW(hwnd, temp, sizeof(temp) / sizeof(wchar_t));
-	dstr_from_wcs(class, temp);
+	if (GetClassNameW(hwnd, temp, sizeof(temp) / sizeof(wchar_t)))
+		dstr_from_wcs(class, temp);
 }
 }
 
 
 static void add_window(obs_property_t *p, HWND hwnd)
 static void add_window(obs_property_t *p, HWND hwnd)