Changeset 1016 for trunk/dll/dircnrs.c


Ignore:
Timestamp:
May 12, 2008, 3:19:05 AM (17 years ago)
Author:
Steven Levine
Message:

Add stale dcd sanity checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r1012 r1016  
    3636  15 Feb 08 SHL Sync with settings menu rework
    3737  22 Feb 08 JBS Ticket 230: Fix/improve various code related to state or presparam values in the INI file.
     38  11 May 08 GKY Avoid using stale dcd after free
     39  11 May 08 SHL Add stale dcd sanity checks
    3840
    3941***********************************************************************/
     
    5961#include "strutil.h"                    // GetPString
    6062#include "notebook.h"                   // CfgDlgProc
    61 #include "command.h"                    // RunCommand
     63#include "command.h"                    // RunCommand
    6264#include "fm3dll.h"
    6365#include "fortify.h"
     
    602604      cni.pRecord = NULL;
    603605      cni.pDragInfo = (PDRAGINFO) mp1;
    604       // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
    605606      li =
    606607        DoFileDrop(dcd->hwndCnr, dcd->directory, FALSE, MPVOID,
     
    14971498      }
    14981499       SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1499                                 DIR_FILTER), &dcd->mask, FALSE);
     1500                                DIR_FILTER), &dcd->mask, FALSE);
    15001501       SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1501                               DIR_SORT), dcd->sortFlags, FALSE);
     1502                              DIR_SORT), dcd->sortFlags, FALSE);
    15021503       SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1503                               DIR_VIEW), dcd->flWindowAttr);
     1504                              DIR_VIEW), dcd->flWindowAttr);
    15041505    }
    15051506    else {
     
    15131514      AdjustCnrColsForPref(hwnd, NULL, dcd, FALSE);
    15141515      SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1515                 DIR_FILTER), &dcd->mask, FALSE);
     1516                DIR_FILTER), &dcd->mask, FALSE);
    15161517      SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1517               DIR_SORT), dcd->sortFlags, FALSE);
     1518              DIR_SORT), dcd->sortFlags, FALSE);
    15181519      SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1519               DIR_VIEW), dcd->flWindowAttr);
     1520              DIR_VIEW), dcd->flWindowAttr);
    15201521    } else
    15211522      PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
     
    15281529
    15291530      if (hwndMenu == DirCnrMenu ||
    1530           hwndMenu == FileMenu || hwndMenu == DirMenu) {
     1531          hwndMenu == FileMenu ||
     1532          hwndMenu == DirMenu) {
    15311533        MarkAll(hwnd, TRUE, FALSE, TRUE);
    15321534        if (dcd->cnremphasized) {
     
    20772079                                    DIR_FILTER), &dcd->mask, FALSE);
    20782080        }
    2079         break;
     2081        break;
    20802082
    20812083      case IDM_UNHIDEALL:
    2082         WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
    2083         break;
     2084        WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
     2085        break;
    20842086
    20852087      case IDM_HIDEALL:
     
    28862888          ULONG action = UM_ACTION;
    28872889
    2888           // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
    28892890          li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
    28902891          CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
     
    33213322    if (dcd) {
    33223323      dcd->stopflag++;
    3323       //printf("%i %x %x %x\n", dcd->dontclose, dcd->hwndFrame, dcd->hwndObject, dcd);
    33243324      if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
    3325         PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
     3325        PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
    33263326      if (dcd->hwndObject) {
    3327           WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
    3328           PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
     3327          // Ensure object window destroy does not attempt duplicate clean up
     3328          WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
     3329          if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
     3330            Win_Error(dcd->hwndObject, hwnd, pszSrcFile, __LINE__, "hwndObject WinPostMsg failed");
    33293331      }
    33303332      if (dcd->hwndRestore)
    3331         WinSetWindowPos(dcd->hwndRestore,
    3332                         HWND_TOP,
    3333                         0,
    3334                         0,
    3335                         0,
    3336                         0,
    3337                         SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
    3338       //printf("%i %x %x %x\n", dcd->dontclose, dcd->hwndFrame, dcd->hwndObject, dcd);
     3333        WinSetWindowPos(dcd->hwndRestore,
     3334                        HWND_TOP,
     3335                        0,
     3336                        0,
     3337                        0,
     3338                        0,
     3339                        SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
    33393340      FreeList(dcd->lastselection);
    33403341      xfree(dcd, pszSrcFile, __LINE__);
    33413342      WinSetWindowPtr(hwnd, QWL_USER, NULL);
    3342       //printf("%i %x %x %x\n", dcd->dontclose, dcd->hwndFrame, dcd->hwndObject, dcd);
    33433343      //Fortify_LeaveScope();
    33443344      DosPostEventSem(CompactSem);
     
    33583358    EmptyCnr(hwnd);
    33593359    break;
    3360   }
    3361   if (dcd && dcd->oldproc){
     3360  } // switch
     3361
     3362  if (dcd && dcd->oldproc) {
     3363      // 11 May 08 SHL fixme debug fortify
     3364      if ((ULONG)dcd->oldproc == 0xa9a9a9a9)
     3365        DbgMsg(pszSrcFile, __LINE__, "calling oldproc after dcd free msg %x mp1 %x mp2 %x", msg, mp1, mp2);
    33623366      return dcd->oldproc(hwnd, msg, mp1, mp2);
    33633367  }
     
    34243428      dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
    34253429      if (!dcd) {
    3426         PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
     3430        PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
    34273431        hwndFrame = (HWND) 0;
    34283432      }
     
    34723476                     IDS_WINCREATEWINDOW);
    34733477          PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
    3474           xfree(dcd, pszSrcFile, __LINE__);
     3478          xfree(dcd, pszSrcFile, __LINE__);
    34753479          hwndFrame = (HWND) 0;
    34763480        }
    34773481        else {
    3478           RestorePresParams(dcd->hwndCnr, "DirCnr");
     3482          RestorePresParams(dcd->hwndCnr, "DirCnr");
    34793483          WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
    34803484          dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
    3481                                            (PFNWP) DirCnrWndProc);
     3485                                           (PFNWP) DirCnrWndProc);
    34823486          {
    34833487            USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
Note: See TracChangeset for help on using the changeset viewer.