Fix of HBITMAP leak in GAPI driver by Dmitry Yakimov. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Mon, 11 Dec 2006 19:51:19 +0000
branchSDL-1.2
changeset 3902 aa07730d792f
parent 3901 3a7248359cdd
child 3903 5baad3758427
Fix of HBITMAP leak in GAPI driver by Dmitry Yakimov. Fixes Bugzilla #371.
src/video/gapi/SDL_gapivideo.c
--- a/src/video/gapi/SDL_gapivideo.c	Fri Dec 01 20:26:06 2006 +0000
+++ b/src/video/gapi/SDL_gapivideo.c	Mon Dec 11 19:51:19 2006 +0000
@@ -1178,7 +1178,7 @@
 	// draw current offscreen buffer on hdc
 
 	int bpp = 16; // we always use either 8 or 16 bpp internally
-
+	HGDIOBJ prevObject;
 	unsigned short *bitmapData;
 	HBITMAP hb;
 	HDC srcDC;
@@ -1216,10 +1216,11 @@
 	// FIXME: prevent misalignment, but I've never seen non aligned width of screen
 	memcpy(bitmapData, this->hidden->buffer, pHeader->biSizeImage);
 	srcDC = CreateCompatibleDC(hdc);
-	SelectObject(srcDC, hb);
+	prevObject = SelectObject(srcDC, hb);
 
 	BitBlt(hdc, 0, 0, this->hidden->w, this->hidden->h, srcDC, 0, 0, SRCCOPY);
 
+	SelectObject(srcDC, prevObject);
 	DeleteObject(hb);
 	DeleteDC(srcDC);
 }