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 3902aa07730d792f
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
     1.1 --- a/src/video/gapi/SDL_gapivideo.c	Fri Dec 01 20:26:06 2006 +0000
     1.2 +++ b/src/video/gapi/SDL_gapivideo.c	Mon Dec 11 19:51:19 2006 +0000
     1.3 @@ -1178,7 +1178,7 @@
     1.4  	// draw current offscreen buffer on hdc
     1.5  
     1.6  	int bpp = 16; // we always use either 8 or 16 bpp internally
     1.7 -
     1.8 +	HGDIOBJ prevObject;
     1.9  	unsigned short *bitmapData;
    1.10  	HBITMAP hb;
    1.11  	HDC srcDC;
    1.12 @@ -1216,10 +1216,11 @@
    1.13  	// FIXME: prevent misalignment, but I've never seen non aligned width of screen
    1.14  	memcpy(bitmapData, this->hidden->buffer, pHeader->biSizeImage);
    1.15  	srcDC = CreateCompatibleDC(hdc);
    1.16 -	SelectObject(srcDC, hb);
    1.17 +	prevObject = SelectObject(srcDC, hb);
    1.18  
    1.19  	BitBlt(hdc, 0, 0, this->hidden->w, this->hidden->h, srcDC, 0, 0, SRCCOPY);
    1.20  
    1.21 +	SelectObject(srcDC, prevObject);
    1.22  	DeleteObject(hb);
    1.23  	DeleteDC(srcDC);
    1.24  }