From 50096f107de419136ec3eb8a692759651994bb14 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 14 Sep 2014 13:54:16 +0000 Subject: crash fix for bad skin images git-svn-id: http://svn.miranda-ng.org/main/trunk@10446 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/modern_skinengine.cpp | 33 +++++++++++--------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'plugins/Clist_modern') diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index 4336a30413..48965be1f0 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -1031,35 +1031,32 @@ HRGN ske_CreateOpaqueRgn(BYTE Level, bool Opaque) if (!g_pCachedWindow) return NULL; - RGBQUAD * buf = (RGBQUAD *) g_pCachedWindow->hImageDIBByte; + RGBQUAD *buf = (RGBQUAD *) g_pCachedWindow->hImageDIBByte; + if (buf == NULL) + return NULL; - int x,y; unsigned int cRect = 64; PRGNDATA pRgnData = (PRGNDATA)malloc(sizeof(RGNDATAHEADER) + (cRect)*sizeof(RECT)); memset(pRgnData, 0, sizeof(RGNDATAHEADER)); pRgnData->rdh.dwSize = sizeof(RGNDATAHEADER); pRgnData->rdh.iType = RDH_RECTANGLES; - for (y = 0; y < g_pCachedWindow->Height; ++y) - { + for (int y = 0; y < g_pCachedWindow->Height; ++y) { bool inside = false; bool lastin = false; unsigned int entry = 0; - for (x = 0; x < g_pCachedWindow->Width; ++x) - { + for (int x = 0; x < g_pCachedWindow->Width; ++x) { inside = Opaque ? (buf->rgbReserved > Level) : (buf->rgbReserved < Level); ++buf; - if (inside != lastin) - { - if (inside) - { + if (inside != lastin) { + if (inside) { lastin = true; entry = x; - } else { - if (pRgnData->rdh.nCount == cRect) - { + } + else { + if (pRgnData->rdh.nCount == cRect) { cRect = cRect + 64; pRgnData = (PRGNDATA)realloc(pRgnData, sizeof(RGNDATAHEADER) + (cRect)*sizeof(RECT)); } @@ -1071,21 +1068,19 @@ HRGN ske_CreateOpaqueRgn(BYTE Level, bool Opaque) } } - if (lastin) - { - if (pRgnData->rdh.nCount == cRect) - { + if (lastin) { + if (pRgnData->rdh.nCount == cRect) { cRect = cRect + 64; pRgnData = (PRGNDATA)realloc(pRgnData, sizeof(RGNDATAHEADER) + (cRect)*sizeof(RECT)); } - SetRect(((LPRECT)pRgnData->Buffer) + pRgnData->rdh.nCount, entry, g_pCachedWindow->Height - y, x, g_pCachedWindow->Height - y + 1); + SetRect(((LPRECT)pRgnData->Buffer) + pRgnData->rdh.nCount, entry, g_pCachedWindow->Height - y, g_pCachedWindow->Width, g_pCachedWindow->Height - y + 1); pRgnData->rdh.nCount++; } } + HRGN hRgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + pRgnData->rdh.nCount*sizeof(RECT), (LPRGNDATA)pRgnData); free(pRgnData); - return hRgn; } -- cgit v1.2.3