Changeset 1614 for trunk/src


Ignore:
Timestamp:
Nov 5, 1999, 1:57:36 PM (26 years ago)
Author:
phaller
Message:

Fix: TREEVIEW_Edit_Subclass is called with freed infoPtr

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/treeview.c

    r1565 r1614  
    1 /* $Id: treeview.c,v 1.13 1999-11-02 21:44:04 achimha Exp $ */
     1/* $Id: treeview.c,v 1.14 1999-11-05 12:53:06 phaller Exp $ */
    22/* Treeview control
    33 *
     
    5151#include "treeview.h"
    5252
    53 
    5453/* ffs should be in <string.h>. */
    5554
     
    966965    }
    967966
    968    
     967
    969968    GetClientRect (hwnd, &rect);
    970969    if ((rect.left-rect.right ==0) || (rect.top-rect.bottom==0)) return;
    971970
    972     infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify 
     971    infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
    973972                                                (hwnd, CDDS_PREPAINT, hdc, rect);
    974973
     
    987986
    988987    /* draw background */
    989    
     988
    990989    hbrBk = CreateSolidBrush (infoPtr->clrBk);
    991990    FillRect(hdc, &rect, hbrBk);
     
    10171016/* FIXME: remove this in later stage  */
    10181017/*
    1019                 if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A) 
     1018                if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A)
    10201019                TRACE (treeview, "%d %d [%d %d %d %d] (%s)\n",y,x,
    10211020                        wineItem->rect.top, wineItem->rect.bottom,
    10221021                        wineItem->rect.left, wineItem->rect.right,
    10231022                        wineItem->pszText);
    1024                 else 
     1023                else
    10251024                TRACE (treeview, "%d [%d %d %d %d] (CALLBACK)\n",
    10261025                                wineItem->hItem,
     
    10791078                        ShowScrollBar (hwnd, SB_VERT, TRUE);
    10801079                infoPtr->uInternalStatus |=TV_VSCROLL;
    1081                 SetScrollRange (hwnd, SB_VERT, 0, 
     1080                SetScrollRange (hwnd, SB_VERT, 0,
    10821081                                        y - infoPtr->uVisibleHeight, FALSE);
    10831082                SetScrollPos (hwnd, SB_VERT, infoPtr->cy, TRUE);
    10841083        }
    10851084    else {
    1086                 if (infoPtr->uInternalStatus & TV_VSCROLL) 
     1085                if (infoPtr->uInternalStatus & TV_VSCROLL)
    10871086                        ShowScrollBar (hwnd, SB_VERT, FALSE);
    10881087                infoPtr->uInternalStatus &= ~TV_VSCROLL;
     
    10901089
    10911090
    1092         if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT) 
    1093         infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify 
     1091        if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT)
     1092        infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
    10941093                                                                (hwnd, CDDS_POSTPAINT, hdc, rect);
    10951094
     
    20202019}
    20212020
     2021
     2022//@@@PH: Note - this SubclassProc is sometimes called with the
     2023//       wrong window handle. Therefore, infoPtr points to anything
     2024//       but the expected structure.
    20222025LRESULT CALLBACK
    20232026TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam,
     
    20432046    {
    20442047      TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(GetParent(hwnd));
    2045       return CallWindowProcA( infoPtr->wpEditOrig, hwnd, uMsg, wParam, lParam);
     2048
     2049      //@@@PH 1999/11/05 method called with freed infoPtr memory object
     2050      if (infoPtr != NULL)
     2051        return CallWindowProcA( infoPtr->wpEditOrig, hwnd, uMsg, wParam, lParam);
     2052      else
     2053        break;
    20462054    }
    20472055  }
     
    21762184    infoPtr->himlNormal = NULL;
    21772185    infoPtr->himlState = NULL;
    2178         infoPtr->uItemHeight = -1;
     2186    infoPtr->uItemHeight = -1;
    21792187    GetTextMetricsA (hdc, &tm);
    21802188    infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT);
    2181         GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
    2182         logFont.lfWeight=FW_BOLD;
     2189    GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
     2190    logFont.lfWeight=FW_BOLD;
    21832191    infoPtr->hBoldFont = CreateFontIndirectA (&logFont);
    21842192
     
    21892197    infoPtr->pCallBackSort=NULL;
    21902198    infoPtr->uScrollTime = 300; /* milliseconds */
     2199
     2200    // @@@PH 1999/11/05
     2201    infoPtr->wpEditOrig = NULL; /* no subclass */
    21912202
    21922203/*
     
    22432254                                    infoPtr->hwndEdit,
    22442255                                    GWL_WNDPROC,
    2245                                                                 (LONG) TREEVIEW_Edit_SubclassProc);
     2256                                    (LONG) TREEVIEW_Edit_SubclassProc);
    22462257
    22472258  ReleaseDC (hwnd, hdc);
     
    22572268
    22582269//   TRACE (treeview,"\n");
     2270
    22592271   TREEVIEW_RemoveTree (hwnd);
     2272
     2273   //@@@PH 1999/11/05 set infoPtr to NULL
     2274   SetWindowLongA( hwnd, 0, (DWORD)NULL);
     2275
    22602276   if (infoPtr->Timer & TV_REFRESH_TIMER_SET)
    22612277        KillTimer (hwnd, TV_REFRESH_TIMER);
     
    22642280
    22652281   COMCTL32_Free (infoPtr);
     2282
    22662283   return 0;
    22672284}
Note: See TracChangeset for help on using the changeset viewer.