summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-09-14 13:54:16 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-09-14 13:54:16 +0000
commit50096f107de419136ec3eb8a692759651994bb14 (patch)
tree59fad9edf5acf8b1a7cdba2b7042c3ec9bb221dd
parent3a2f0f180e14ab7436370c5420903b31a5c248a1 (diff)
crash fix for bad skin images
git-svn-id: http://svn.miranda-ng.org/main/trunk@10446 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Clist_modern/src/modern_skinengine.cpp33
1 files changed, 14 insertions, 19 deletions
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;
}