Pārlūkot izejas kodu

win-capture: Fix crash if cursor size is zero

Ryan Foster 5 mēneši atpakaļ
vecāks
revīzija
8bf9ec6945
1 mainītis faili ar 6 papildinājumiem un 0 dzēšanām
  1. 6 0
      plugins/win-capture/cursor-capture.c

+ 6 - 0
plugins/win-capture/cursor-capture.c

@@ -7,6 +7,9 @@ static uint8_t *get_bitmap_data(HBITMAP hbmp, BITMAP *bmp)
 	if (GetObject(hbmp, sizeof(*bmp), bmp) != 0) {
 	if (GetObject(hbmp, sizeof(*bmp), bmp) != 0) {
 		uint8_t *output;
 		uint8_t *output;
 		unsigned int size = bmp->bmHeight * bmp->bmWidthBytes;
 		unsigned int size = bmp->bmHeight * bmp->bmWidthBytes;
+		if (!size) {
+			return NULL;
+		}
 
 
 		output = bmalloc(size);
 		output = bmalloc(size);
 		GetBitmapBits(hbmp, size, output);
 		GetBitmapBits(hbmp, size, output);
@@ -99,6 +102,9 @@ static inline uint8_t *copy_from_mask(ICONINFO *ii, uint32_t *width, uint32_t *h
 	bmp.bmHeight /= 2;
 	bmp.bmHeight /= 2;
 
 
 	pixels = bmp.bmHeight * bmp.bmWidth;
 	pixels = bmp.bmHeight * bmp.bmWidth;
+	if (!pixels) {
+		return NULL;
+	}
 	output = bzalloc(pixels * 4);
 	output = bzalloc(pixels * 4);
 
 
 	bottom = bmp.bmWidthBytes * bmp.bmHeight;
 	bottom = bmp.bmWidthBytes * bmp.bmHeight;