changeset 3902:aa07730d792f SDL-1.2

Fix of HBITMAP leak in GAPI driver by Dmitry Yakimov. Fixes Bugzilla #371.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 11 Dec 2006 19:51:19 +0000
parents 3a7248359cdd
children 5baad3758427
files src/video/gapi/SDL_gapivideo.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);
 }