# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1045635839 0 # Node ID 36013ddd3f5b9eb5613893d93e966e20d92155db # Parent 00d2b1bcf0366cf06ba7d9afba8dc01ac057d0f3 Fixes for Windows code. diff -r 00d2b1bcf036 -r 36013ddd3f5b win/dw.c --- a/win/dw.c Wed Feb 19 06:00:54 2003 +0000 +++ b/win/dw.c Wed Feb 19 06:23:59 2003 +0000 @@ -6698,10 +6698,15 @@ HPIXMAP pixmap; BITMAP bm; HDC hdc; - char *file = alloca(strlen(filename) + 5); + SIZE sz; + char *file = malloc(strlen(filename) + 5); if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap)))) + { + if(file) + free(file); return NULL; + } strcpy(file, filename); @@ -6713,22 +6718,36 @@ if(access(file, 04) != 0) { free(pixmap); + free(file); return NULL; } } - dc = GetDC(handle); - - pixmap->width = width; pixmap->height = height; + hdc = GetDC(handle); pixmap->handle = handle; pixmap->hbm = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); + + if(!pixmap->hbm) + { + free(file); + free(pixmap); + ReleaseDC(handle, hdc); + return NULL; + } + pixmap->hdc = CreateCompatibleDC(hdc); + GetBitmapDimensionEx(pixmap->hbm, &sz); + + pixmap->width = sz.cx; pixmap->height = sz.cy; + SelectObject(pixmap->hdc, pixmap->hbm); ReleaseDC(handle, hdc); + free(file); + return pixmap; }