Changeset 1836 for trunk/dll/dircnrs.c


Ignore:
Timestamp:
Jul 15, 2015, 2:48:14 AM (10 years ago)
Author:
Gregg Young
Message:

Fix trap in collector if a pci-pszFileName = NullStr and fix heap corruption problem and its related traps. This code reverts John double free fix. Ticket [551][555]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r1807 r1836  
    9797#include <ctype.h>
    9898#include <limits.h>
     99//#include <malloc.h>                   // _msize _heapchk
    99100// #include <process.h>                 // _beginthread
    100101
     
    169170#include "pathutil.h"                   // AddBackslashToPath
    170171#include "copyf.h"                      // ignorereadonly
     172#if 0
     173#define  __PMPRINTF__
     174#include "PMPRINTF.H"
     175#endif
    171176
    172177// Data definitions
     
    791796      }
    792797      else
    793         *szFree = 0;
     798        *szFree = 0;
     799      DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    794800      commafmt(tf, sizeof(tf), dcd->totalfiles);
    795801      CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
     802      DosReleaseMutexSem(hmtxFiltering);
    796803      if (!fMoreButtons) {
    797804        sprintf(s, " [%s / %s]%s%s%s%s %s",
     
    873880      RemoveCnrItems(dcd->hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
    874881      AdjustCnrColsForFSType(dcd->hwndCnr, dcd->directory, &dcd->ds, FALSE);
    875       dcd->ullTotalBytes = dcd->totalfiles =
    876         dcd->selectedfiles = dcd->selectedbytes = 0;
     882      DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
     883      dcd->ullTotalBytes = dcd->totalfiles = dcd->selectedfiles = dcd->selectedbytes = 0;
     884      DosReleaseMutexSem(hmtxFiltering);
    877885      WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0 / 0k");
    878886      WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
     
    12201228      DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    12211229      xfree(dcd, pszSrcFile, __LINE__);
     1230      dcd = NULL;
    12221231      DosReleaseMutexSem(hmtxFiltering);
    12231232      DosPostEventSem(CompactSem);
     
    14751484      cnri.pszCnrTitle = dcd->directory;
    14761485      WinSendMsg(hwnd,
    1477                  CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
     1486                 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
     1487      DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    14781488      dcd->totalfiles = cnri.cRecords;
    14791489      commafmt(tb, sizeof(tb), dcd->totalfiles);
    14801490      CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K');
     1491      DosReleaseMutexSem(hmtxFiltering);
    14811492      sprintf(s, "%s / %s", tb, tf);
    14821493      WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
     
    32583269          else {
    32593270
    3260             MRESULT mre;
    3261 
    3262             mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
     3271            MRESULT mre;
     3272
     3273            mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
    32633274            if (mre != (MRESULT) - 1)
    32643275              return mre;
     
    33043315            }
    33053316          }
    3306           if (!dcd->suspendview && hwndMain &&
     3317          if (!dcd->suspendview && hwndMain && pci->pszFileName != NullStr &&
    33073318              (pre->fEmphasisMask & CRA_CURSORED) &&
    33083319              (pci->rc.flRecordAttr & CRA_CURSORED) &&
     
    35133524    WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
    35143525    if (LastDir == hwnd)
    3515       LastDir = (HWND) 0;
     3526        LastDir = (HWND) 0;
     3527    DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    35163528    if (dcd) {
    35173529      dcd->stopflag++;
     
    35333545                        SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
    35343546      FreeList(dcd->lastselection);
    3535       DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    3536       free(dcd);
    3537       DosReleaseMutexSem(hmtxFiltering);
    35383547      WinSetWindowPtr(hwnd, QWL_USER, NULL);
    35393548      DosPostEventSem(CompactSem);
    35403549    }
     3550    DosReleaseMutexSem(hmtxFiltering);
    35413551    WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
    35423552                                    QW_PARENT));
     
    35553565    DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
    35563566    EmptyCnr(hwnd);
     3567    DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
     3568    xfree(dcd, pszSrcFile, __LINE__);
     3569    dcd = NULL;
     3570    DosReleaseMutexSem(hmtxFiltering);
    35573571#   ifdef FORTIFY
    35583572    Fortify_LeaveScope();
Note: See TracChangeset for help on using the changeset viewer.