Commit a1b2fc2a authored by Gerard Patel's avatar Gerard Patel Committed by Alexandre Julliard

Protect against use of comctl32 private control memory after it has

been freed.
parent 7b6ed869
...@@ -604,6 +604,7 @@ static LRESULT ANIMATE_Destroy(HWND hWnd, WPARAM wParam, LPARAM lParam) ...@@ -604,6 +604,7 @@ static LRESULT ANIMATE_Destroy(HWND hWnd, WPARAM wParam, LPARAM lParam)
/* free animate info data */ /* free animate info data */
COMCTL32_Free(infoPtr); COMCTL32_Free(infoPtr);
SetWindowLongA(hWnd, 0, 0);
FreeLibrary(hModWinmm); FreeLibrary(hModWinmm);
return 0; return 0;
...@@ -643,6 +644,9 @@ static LRESULT WINAPI ANIMATE_Size(HWND hWnd, WPARAM wParam, LPARAM lParam) ...@@ -643,6 +644,9 @@ static LRESULT WINAPI ANIMATE_Size(HWND hWnd, WPARAM wParam, LPARAM lParam)
static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam);
if (!ANIMATE_GetInfoPtr(hWnd) && (uMsg != WM_NCCREATE))
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
case ACM_OPENA: case ACM_OPENA:
......
...@@ -201,7 +201,7 @@ COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -201,7 +201,7 @@ COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
/* free comboex info data */ /* free comboex info data */
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA (hwnd, 0, 0);
return 0; return 0;
} }
...@@ -224,6 +224,10 @@ COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -224,6 +224,10 @@ COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
static LRESULT WINAPI static LRESULT WINAPI
COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!COMBOEX_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
/* case CBEM_DELETEITEM: */ /* case CBEM_DELETEITEM: */
......
...@@ -1130,7 +1130,7 @@ HEADER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1130,7 +1130,7 @@ HEADER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
ImageList_Destroy (infoPtr->himl); ImageList_Destroy (infoPtr->himl);
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA (hwnd, 0, 0);
return 0; return 0;
} }
...@@ -1454,6 +1454,9 @@ HEADER_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1454,6 +1454,9 @@ HEADER_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
static LRESULT WINAPI static LRESULT WINAPI
HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, msg, wParam, lParam);
if (!HEADER_GetInfoPtr (hwnd) && (msg != WM_CREATE))
return DefWindowProcA (hwnd, msg, wParam, lParam);
switch (msg) { switch (msg) {
case HDM_CREATEDRAGIMAGE: case HDM_CREATEDRAGIMAGE:
return HEADER_CreateDragImage (hwnd, wParam); return HEADER_CreateDragImage (hwnd, wParam);
......
...@@ -66,7 +66,7 @@ HOTKEY_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -66,7 +66,7 @@ HOTKEY_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
/* free hotkey info data */ /* free hotkey info data */
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA (hwnd, 0, 0);
return 0; return 0;
} }
...@@ -269,6 +269,9 @@ HOTKEY_SysKeyUp (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -269,6 +269,9 @@ HOTKEY_SysKeyUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
static LRESULT WINAPI static LRESULT WINAPI
HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!HOTKEY_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
/* case HKM_GETHOTKEY: */ /* case HKM_GETHOTKEY: */
......
...@@ -140,6 +140,7 @@ IPADDRESS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -140,6 +140,7 @@ IPADDRESS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
} }
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA (hwnd, 0, 0);
return 0; return 0;
} }
...@@ -594,6 +595,9 @@ IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -594,6 +595,9 @@ IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static LRESULT WINAPI static LRESULT WINAPI
IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!IPADDRESS_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
case IPM_CLEARADDRESS: case IPM_CLEARADDRESS:
......
...@@ -6710,6 +6710,7 @@ static LRESULT LISTVIEW_NCDestroy(HWND hwnd) ...@@ -6710,6 +6710,7 @@ static LRESULT LISTVIEW_NCDestroy(HWND hwnd)
/* free listview info pointer*/ /* free listview info pointer*/
COMCTL32_Free(infoPtr); COMCTL32_Free(infoPtr);
SetWindowLongA(hwnd, 0, 0);
return 0; return 0;
} }
...@@ -7300,6 +7301,9 @@ static INT LISTVIEW_StyleChanged(HWND hwnd, WPARAM wStyleType, ...@@ -7300,6 +7301,9 @@ static INT LISTVIEW_StyleChanged(HWND hwnd, WPARAM wStyleType,
static LRESULT WINAPI LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, static LRESULT WINAPI LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
TRACE("hwnd=%x uMsg=%x wParam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!GetWindowLongA(hwnd, 0) && (uMsg != WM_NCCREATE))
return DefWindowProcA( hwnd, uMsg, wParam, lParam );
switch (uMsg) switch (uMsg)
{ {
case LVM_APPROXIMATEVIEWRECT: case LVM_APPROXIMATEVIEWRECT:
......
...@@ -1621,7 +1621,7 @@ MONTHCAL_Destroy(HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1621,7 +1621,7 @@ MONTHCAL_Destroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
/* free month calendar info data */ /* free month calendar info data */
COMCTL32_Free(infoPtr); COMCTL32_Free(infoPtr);
SetWindowLongA(hwnd, 0, 0);
return 0; return 0;
} }
...@@ -1629,6 +1629,9 @@ MONTHCAL_Destroy(HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1629,6 +1629,9 @@ MONTHCAL_Destroy(HWND hwnd, WPARAM wParam, LPARAM lParam)
static LRESULT WINAPI static LRESULT WINAPI
MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!MONTHCAL_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
return DefWindowProcA(hwnd, uMsg, wParam, lParam);
switch(uMsg) switch(uMsg)
{ {
case MCM_GETCURSEL: case MCM_GETCURSEL:
......
...@@ -230,7 +230,7 @@ PAGER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -230,7 +230,7 @@ PAGER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
/* free pager info data */ /* free pager info data */
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA (hwnd, 0, 0);
return 0; return 0;
} }
...@@ -290,6 +290,9 @@ PAGER_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -290,6 +290,9 @@ PAGER_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
static LRESULT WINAPI static LRESULT WINAPI
PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!PAGER_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
case PGM_FORWARDMOUSE: case PGM_FORWARDMOUSE:
......
...@@ -198,7 +198,8 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, ...@@ -198,7 +198,8 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
{ {
PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd); PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
UINT temp; UINT temp;
if (!infoPtr && (message != WM_CREATE))
return DefWindowProcA( hwnd, message, wParam, lParam );
switch(message) switch(message)
{ {
case WM_NCCREATE: case WM_NCCREATE:
...@@ -229,6 +230,7 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, ...@@ -229,6 +230,7 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
case WM_DESTROY: case WM_DESTROY:
TRACE("Progress Ctrl destruction, hwnd=%04x\n", hwnd); TRACE("Progress Ctrl destruction, hwnd=%04x\n", hwnd);
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA(hwnd, 0, 0);
break; break;
case WM_ERASEBKGND: case WM_ERASEBKGND:
......
...@@ -1680,7 +1680,7 @@ REBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1680,7 +1680,7 @@ REBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
/* free rebar info data */ /* free rebar info data */
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA (hwnd, 0, 0);
TRACE("destroyed!\n"); TRACE("destroyed!\n");
return 0; return 0;
} }
...@@ -1886,6 +1886,9 @@ REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1886,6 +1886,9 @@ REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
static LRESULT WINAPI static LRESULT WINAPI
REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!REBAR_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
/* case RB_BEGINDRAG: */ /* case RB_BEGINDRAG: */
......
...@@ -901,7 +901,7 @@ STATUSBAR_WMDestroy (HWND hwnd) ...@@ -901,7 +901,7 @@ STATUSBAR_WMDestroy (HWND hwnd)
DestroyWindow (self->hwndToolTip); DestroyWindow (self->hwndToolTip);
COMCTL32_Free (self); COMCTL32_Free (self);
SetWindowLongA(hwnd, 0, 0);
return 0; return 0;
} }
...@@ -1098,6 +1098,10 @@ STATUSBAR_SendNotify (HWND hwnd, UINT code) ...@@ -1098,6 +1098,10 @@ STATUSBAR_SendNotify (HWND hwnd, UINT code)
static LRESULT WINAPI static LRESULT WINAPI
StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);
if (!(STATUSBAR_GetInfoPtr(hwnd)) && (msg != WM_CREATE))
return DefWindowProcA (hwnd, msg, wParam, lParam);
switch (msg) { switch (msg) {
case SB_GETBORDERS: case SB_GETBORDERS:
return STATUSBAR_GetBorders (lParam); return STATUSBAR_GetBorders (lParam);
......
...@@ -1931,12 +1931,18 @@ TAB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1931,12 +1931,18 @@ TAB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
DestroyWindow(infoPtr->hwndUpDown); DestroyWindow(infoPtr->hwndUpDown);
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA(hwnd, 0, 0);
return 0; return 0;
} }
static LRESULT WINAPI static LRESULT WINAPI
TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wParam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!TAB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
case TCM_GETIMAGELIST: case TCM_GETIMAGELIST:
......
...@@ -1961,7 +1961,7 @@ TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1961,7 +1961,7 @@ TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
/* free tool tips info data */ /* free tool tips info data */
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA(hwnd, 0, 0);
return 0; return 0;
} }
...@@ -2233,6 +2233,9 @@ TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -2233,6 +2233,9 @@ TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static LRESULT CALLBACK static LRESULT CALLBACK
TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!(TOOLTIPS_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)))
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
case TTM_ACTIVATE: case TTM_ACTIVATE:
......
...@@ -1118,6 +1118,7 @@ TRACKBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1118,6 +1118,7 @@ TRACKBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
DestroyWindow (infoPtr->hwndToolTip); DestroyWindow (infoPtr->hwndToolTip);
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA (hwnd, 0, 0);
return 0; return 0;
} }
...@@ -1449,6 +1450,9 @@ TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam) ...@@ -1449,6 +1450,9 @@ TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam)
static LRESULT WINAPI static LRESULT WINAPI
TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
if (!TRACKBAR_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
return DefWindowProcA (hwnd, uMsg, wParam, lParam);
switch (uMsg) switch (uMsg)
{ {
case TBM_CLEARSEL: case TBM_CLEARSEL:
......
...@@ -699,7 +699,8 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, ...@@ -699,7 +699,8 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam,
UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
int temp; int temp;
if (!infoPtr && (message != WM_CREATE) && (message != WM_NCCREATE))
return DefWindowProcA (hwnd, message, wParam, lParam);
switch(message) switch(message)
{ {
case WM_NCCREATE: case WM_NCCREATE:
...@@ -733,7 +734,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, ...@@ -733,7 +734,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam,
RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND); RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
COMCTL32_Free (infoPtr); COMCTL32_Free (infoPtr);
SetWindowLongA (hwnd, 0, 0);
TRACE("UpDown Ctrl destruction, hwnd=%04x\n", hwnd); TRACE("UpDown Ctrl destruction, hwnd=%04x\n", hwnd);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment