Changeset 1836
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/collect.c
r1803 r1836 89 89 02 May 15 GKY Changes to allow a JAVA executable object to be created using "Real object" 90 90 menu item on a jar file. 91 14 Jun 15 GKY Changes to prevent trap in Filter 91 92 92 93 ***********************************************************************/ … … 748 749 } 749 750 else { 750 // Update OK 751 if (Filter((PMINIRECORDCORE) pciUpd, (PVOID) & dcd->mask)) { 751 // Update OK 752 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 753 if (dcd && Filter((PMINIRECORDCORE) pciUpd, (PVOID) & dcd->mask)) { 752 754 pciUpd->rc.flRecordAttr &= ~CRA_FILTERED; // Ensure visible 753 755 // 2011-05-29 SHL fixme to check fail 754 756 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID, 755 757 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE)); 756 } 758 } 759 DosReleaseMutexSem(hmtxFiltering); 757 760 } 758 761 ulMaxFiles--; // No insert needed … … 913 916 TRUE)) { 914 917 // Already in container 915 pci = UpdateCnrRecord(dcd->hwndCnr, fullname, FALSE, dcd); 916 if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) { 918 pci = UpdateCnrRecord(dcd->hwndCnr, fullname, FALSE, dcd); 919 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 920 if (dcd && Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) { 917 921 pci->rc.flRecordAttr &= ~CRA_FILTERED; 918 922 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID, 919 923 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE)); 920 } 924 } 925 DosReleaseMutexSem(hmtxFiltering); 921 926 } 922 927 else if (IsFullName(fullname) && … … 1168 1173 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 1169 1174 free(dcd); 1175 dcd = NULL; 1170 1176 DosReleaseMutexSem(hmtxFiltering); 1171 1177 # ifdef FORTIFY … … 1425 1431 p = pci->pszFileName; 1426 1432 else { 1427 if (!pci->pszFileName) 1428 Runtime_Error(pszSrcFile, __LINE__, "pci->pszFileName NULL for %p", pci); 1429 p = strrchr(pci->pszFileName, '\\'); 1433 if (!pci->pszFileName) { 1434 Runtime_Error(pszSrcFile, __LINE__, "pci->pszFileName NULL for %p", pci); 1435 return 0; 1436 } 1437 p = strrchr(pci->pszFileName, '\\'); 1430 1438 if (p) { 1431 1439 if (*(p + 1)) … … 2128 2136 // 2013-12-13 SHL Allow nul pszFileName 2129 2137 pci = (PCNRITEM) CurrentRecord(hwnd); 2130 if (pci && pci->pszFileName && ~pci->attrFile & FILE_DIRECTORY) {2138 if (pci && pci->pszFileName != NullStr && ~pci->attrFile & FILE_DIRECTORY) { 2131 2139 p = strrchr(pci->pszFileName, '\\'); 2132 2140 if (p) { … … 2815 2823 case CN_ENDEDIT: 2816 2824 { 2817 MRESULT mre;2818 2819 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);2825 MRESULT mre; 2826 2827 mre = CnrDirectEdit(hwnd, msg, mp1, mp2); 2820 2828 if (mre != (MRESULT) - 1) 2821 2829 return mre; -
trunk/dll/comp.c
r1686 r1836 91 91 Added saymsg2 for this purpose 92 92 10 Mar 13 GKY Fixes to snapshot file. 93 14 Jun 15 GKY Changes to prvenet access violations when cmp is freed 93 94 94 95 ***********************************************************************/ … … 944 945 # endif 945 946 } 946 else 947 else { 948 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 947 949 free(cmp); 950 cmp = NULL; 951 DosReleaseMutexSem(hmtxFiltering); 952 } 948 953 } 949 954 … … 1994 1999 pcil->crtime.seconds = filesl[l]->crtime.twosecs * 2; 1995 2000 pcil->crtime.minutes = filesl[l]->crtime.minutes; 1996 pcil->crtime.hours = filesl[l]->crtime.hours; 1997 if (*cmp->dcd.mask.szMask) { 2001 pcil->crtime.hours = filesl[l]->crtime.hours; 2002 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 2003 if (cmp && *cmp->dcd.mask.szMask) { 1998 2004 if (!Filter((PMINIRECORDCORE)pcil, (PVOID)&cmp->dcd.mask)) { 1999 2005 pcil->rc.flRecordAttr |= CRA_FILTERED; 2000 2006 pcir->rc.flRecordAttr |= CRA_FILTERED; 2001 } 2002 } 2007 } 2008 } 2009 DosReleaseMutexSem(hmtxFiltering); 2003 2010 } // if on left 2004 2011 … … 2036 2043 pcir->crtime.minutes = filesr[r]->crtime.minutes; 2037 2044 pcir->crtime.hours = filesr[r]->crtime.hours; 2038 // Bypass check if already filtered on left side 2039 if (~pcir->rc.flRecordAttr & CRA_FILTERED && 2045 // Bypass check if already filtered on left side 2046 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 2047 if (cmp && ~pcir->rc.flRecordAttr & CRA_FILTERED && 2040 2048 *cmp->dcd.mask.szMask) { 2041 2049 if (!Filter((PMINIRECORDCORE)pcir, (PVOID)&cmp->dcd.mask)) { 2042 2050 pcil->rc.flRecordAttr |= CRA_FILTERED; 2043 2051 pcir->rc.flRecordAttr |= CRA_FILTERED; 2044 } 2045 } 2052 } 2053 } 2054 DosReleaseMutexSem(hmtxFiltering); 2046 2055 } // if on right 2047 2056 … … 2241 2250 WinTerminate(hab); 2242 2251 } 2252 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 2243 2253 free(cmp); 2254 cmp = NULL; 2255 DosReleaseMutexSem(hmtxFiltering); 2244 2256 DosPostEventSem(CompactSem); 2245 2257 … … 2566 2578 // 01 Aug 07 SHL if field null or blank, we draw 2567 2579 // fixme to document why - probably to optimize and bypass draw? 2568 if (pci && (INT)pci != -1 && !*pci->pszFileName )2580 if (pci && (INT)pci != -1 && !*pci->pszFileName && pci->pszFileName != NullStr) 2569 2581 return MRFROMLONG(TRUE); 2570 2582 } … … 3542 3554 WinSendMsg(cmp->dcd.hwndObject, WM_CLOSE, MPVOID, MPVOID); 3543 3555 } 3556 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 3544 3557 free(cmp); 3558 cmp = NULL; 3559 DosReleaseMutexSem(hmtxFiltering); 3545 3560 } 3546 3561 EmptyCnr(GetHwndLeft(hwnd)); -
trunk/dll/dircnrs.c
r1807 r1836 97 97 #include <ctype.h> 98 98 #include <limits.h> 99 //#include <malloc.h> // _msize _heapchk 99 100 // #include <process.h> // _beginthread 100 101 … … 169 170 #include "pathutil.h" // AddBackslashToPath 170 171 #include "copyf.h" // ignorereadonly 172 #if 0 173 #define __PMPRINTF__ 174 #include "PMPRINTF.H" 175 #endif 171 176 172 177 // Data definitions … … 791 796 } 792 797 else 793 *szFree = 0; 798 *szFree = 0; 799 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 794 800 commafmt(tf, sizeof(tf), dcd->totalfiles); 795 801 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' '); 802 DosReleaseMutexSem(hmtxFiltering); 796 803 if (!fMoreButtons) { 797 804 sprintf(s, " [%s / %s]%s%s%s%s %s", … … 873 880 RemoveCnrItems(dcd->hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE); 874 881 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); 877 885 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0 / 0k"); 878 886 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k"); … … 1220 1228 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 1221 1229 xfree(dcd, pszSrcFile, __LINE__); 1230 dcd = NULL; 1222 1231 DosReleaseMutexSem(hmtxFiltering); 1223 1232 DosPostEventSem(CompactSem); … … 1475 1484 cnri.pszCnrTitle = dcd->directory; 1476 1485 WinSendMsg(hwnd, 1477 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE)); 1486 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE)); 1487 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 1478 1488 dcd->totalfiles = cnri.cRecords; 1479 1489 commafmt(tb, sizeof(tb), dcd->totalfiles); 1480 1490 CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K'); 1491 DosReleaseMutexSem(hmtxFiltering); 1481 1492 sprintf(s, "%s / %s", tb, tf); 1482 1493 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s); … … 3258 3269 else { 3259 3270 3260 MRESULT mre;3261 3262 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);3271 MRESULT mre; 3272 3273 mre = CnrDirectEdit(hwnd, msg, mp1, mp2); 3263 3274 if (mre != (MRESULT) - 1) 3264 3275 return mre; … … 3304 3315 } 3305 3316 } 3306 if (!dcd->suspendview && hwndMain && 3317 if (!dcd->suspendview && hwndMain && pci->pszFileName != NullStr && 3307 3318 (pre->fEmphasisMask & CRA_CURSORED) && 3308 3319 (pci->rc.flRecordAttr & CRA_CURSORED) && … … 3513 3524 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID); 3514 3525 if (LastDir == hwnd) 3515 LastDir = (HWND) 0; 3526 LastDir = (HWND) 0; 3527 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 3516 3528 if (dcd) { 3517 3529 dcd->stopflag++; … … 3533 3545 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER); 3534 3546 FreeList(dcd->lastselection); 3535 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);3536 free(dcd);3537 DosReleaseMutexSem(hmtxFiltering);3538 3547 WinSetWindowPtr(hwnd, QWL_USER, NULL); 3539 3548 DosPostEventSem(CompactSem); 3540 3549 } 3550 DosReleaseMutexSem(hmtxFiltering); 3541 3551 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), 3542 3552 QW_PARENT)); … … 3555 3565 DirMenu = DirCnrMenu = FileMenu = (HWND) 0; 3556 3566 EmptyCnr(hwnd); 3567 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 3568 xfree(dcd, pszSrcFile, __LINE__); 3569 dcd = NULL; 3570 DosReleaseMutexSem(hmtxFiltering); 3557 3571 # ifdef FORTIFY 3558 3572 Fortify_LeaveScope(); -
trunk/dll/filldir.c
r1814 r1836 107 107 28 Jun 14 GKY Fix errors identified with CPPCheck 108 108 30 Aug 14 GKY Use saymsg2 for Suggest dialog 109 14 Jun 15 GKY Changes to prevent trap in Filter, heap corruption and traps associated with it 109 110 19 Jun 15 JBS Ticket 514: Double free fix (which also fixes a memory leak) 110 111 … … 153 154 #include "pathutil.h" // AddBackslashToPath 154 155 #include "tmrsvcs.h" // ITIMER_DESC 156 #if 0 157 #define __PMPRINTF__ 158 #include "PMPRINTF.H" 159 #endif 155 160 156 161 VOID StubbyScanThread(VOID * arg); … … 424 429 BOOL fLoadSubjectForDrive = fLoadSubject && ~flags & DRIVE_NOLOADSUBJS; 425 430 BOOL fLoadLongNameForDrive = fLoadLongnames && //~flags & DRIVE_NOLONGNAMES && 426 ~flags & DRIVE_NOLOADLONGS;431 ~flags & DRIVE_NOLOADLONGS; 427 432 if (fLoadSubjectForDrive || fLoadLongNameForDrive) { 428 433 // Allocate space to hold GEA2s and .SUBJECT and .LONGNAME strings 429 PGEA2LIST pgealist = xmallocz(sizeof(GEA2LIST) + sizeof(GEA2) + 64, pszSrcFile, __LINE__); 434 PGEA2LIST pgealist = xmallocz(sizeof(GEA2LIST) + (sizeof(GEA2) * 2) + 32, 435 pszSrcFile, __LINE__); 430 436 if (pgealist) { 431 437 APIRET rc; … … 466 472 //DbgMsg(pszSrcFile, __LINE__, "pgealist %p cbList %u", pgealist, pgealist->cbList); 467 473 468 pfealist = xmallocz( 4096, pszSrcFile, __LINE__);474 pfealist = xmallocz(65536, pszSrcFile, __LINE__); 469 475 if (pfealist) { 470 pfealist->cbList = 4096;476 pfealist->cbList = 65536; 471 477 eaop.fpGEA2List = pgealist; 472 478 eaop.fpFEA2List = pfealist; … … 514 520 pfea = (PFEA2)((PSZ)pfea + pfea->oNextEntryOffset); 515 521 } // while 516 }522 } 517 523 free(pfealist); 518 524 } … … 688 694 pci->rc.hptrIcon = hptr; 689 695 696 690 697 // check to see if record should be visible 698 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 691 699 if (dcd && (*dcd->mask.szMask || dcd->mask.antiattr || 692 700 ((dcd->mask.attrFile & 693 701 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)) 694 != 695 (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) 696 { 702 != (FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY | FILE_ARCHIVED)))) { 697 703 if (*dcd->mask.szMask || dcd->mask.antiattr) { 698 704 if (!Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) 699 pci->rc.flRecordAttr |= CRA_FILTERED;705 pci->rc.flRecordAttr |= CRA_FILTERED; 700 706 } 701 707 else if ((!(dcd->mask.attrFile & FILE_HIDDEN) && … … 710 716 } 711 717 } 718 DosReleaseMutexSem(hmtxFiltering); 712 719 713 720 return pffb->cbFile + pci->easize; … … 851 858 pci->rc.hptrIcon = hptr; 852 859 860 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 853 861 if (dcd && 854 862 (*dcd->mask.szMask || dcd->mask.antiattr || … … 858 866 if (*dcd->mask.szMask || dcd->mask.antiattr) { 859 867 if (!Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) 860 pci->rc.flRecordAttr |= CRA_FILTERED;868 pci->rc.flRecordAttr |= CRA_FILTERED; 861 869 } 862 870 else if ((!(dcd->mask.attrFile & FILE_HIDDEN) && … … 870 878 pci->rc.flRecordAttr |= CRA_FILTERED; 871 879 } 880 DosReleaseMutexSem(hmtxFiltering); 872 881 873 882 return pfsa4->cbFile + pci->easize; … … 968 977 pffbFile = paffbFound; 969 978 ulSelCnt = 0; 970 for (;;) {979 for (;;) { 971 980 if (!*pffbFile->achName || 972 981 (!filestoo && ~pffbFile->attrFile & FILE_DIRECTORY) || … … 989 998 if (stopflag && *stopflag) 990 999 goto Abort; 991 if (fSyncUpdates) { 1000 if (fSyncUpdates) { 1001 if (!WinIsWindow(WinQueryAnchorBlock(hwndCnr), hwndCnr)) { 1002 ok = FALSE; 1003 ullTotalBytes = 0; 1004 break; 1005 } 992 1006 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD, 993 1007 MPFROMLONG(EXTRA_RECORD_BYTES), … … 1005 1019 // Finish filling pci items 1006 1020 for (x = 0; x < ulSelCnt; x++) { 1007 pffbFile = papffbSelected[x];1021 pffbFile = papffbSelected[x]; 1008 1022 ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, 1009 1023 pffbFile, partial, dcd); … … 1039 1053 if (ok) { 1040 1054 ullReturnBytes += ullTotalBytes; 1041 ulReturnFiles += ulSelCnt; 1055 ulReturnFiles += ulSelCnt; 1056 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 1042 1057 if (dcd) { 1043 1058 dcd->totalfiles += ulSelCnt; 1044 1059 dcd->ullTotalBytes += ullTotalBytes; 1045 } 1060 } 1061 DosReleaseMutexSem(hmtxFiltering); 1046 1062 } 1047 1063 } // if sync updates … … 1098 1114 ULONG ulRecsToInsert; 1099 1115 1100 if (pci ==NULL) { 1116 if (pci ==NULL) { 1117 if (!WinIsWindow(WinQueryAnchorBlock(hwndCnr), hwndCnr)) { 1118 ok = FALSE; 1119 ullTotalBytes = 0; 1120 break; 1121 } 1101 1122 ulRecsToInsert = cAffbTotal - x < USHRT_MAX ? cAffbTotal - x : USHRT_MAX; 1102 1123 pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD, 1103 1124 MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(ulRecsToInsert)); 1104 1125 1105 if (!pciFirst) { 1126 if (!pciFirst) { 1127 //ERRORID erridErrorCode = WinGetLastError(WinQueryAnchorBlock(hwndCnr)); 1128 //PmpfF(("Allocation failed %i", erridErrorCode)); 1106 1129 Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, 1107 1130 GetPString(IDS_CMALLOCRECERRTEXT)); … … 1118 1141 pci = pciFirst; 1119 1142 } 1120 }1143 } 1121 1144 ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, 1122 1145 pffbFile, partial, dcd); 1123 1146 pci = (PCNRITEM) pci->rc.preccNextRecord; 1124 1147 ullTotalBytes += ullBytes; 1125 // 15 Sep 09 SHL allow timed updates to see 1148 // 15 Sep 09 SHL allow timed updates to see 1149 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 1126 1150 if (dcd) { 1127 1151 dcd->totalfiles = x; 1128 1152 dcd->ullTotalBytes = ullTotalBytes; 1129 } 1153 } 1154 DosReleaseMutexSem(hmtxFiltering); 1130 1155 // Can not use offset since we have merged lists - this should be equivalent 1131 1156 pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + sizeof(FILEFINDBUF4L)); 1132 1157 1133 if (!IdleIfNeeded(&itdSleep, 30)) {1134 for (x = x+1; x < cAffbTotal; x++) {1158 if (!IdleIfNeeded(&itdSleep, 30)) { 1159 for (x = x+1; x < cAffbTotal; x++) { 1135 1160 ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec, 1136 1161 pffbFile, partial, dcd); 1137 1162 pci = (PCNRITEM) pci->rc.preccNextRecord; 1138 ullTotalBytes += ullBytes; 1163 ullTotalBytes += ullBytes; 1164 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT); 1139 1165 if (dcd) { 1140 1166 dcd->totalfiles = x; 1141 1167 dcd->ullTotalBytes = ullTotalBytes; 1142 } 1143 pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + sizeof(FILEFINDBUF4L)); 1168 } 1169 DosReleaseMutexSem(hmtxFiltering); 1170 pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + sizeof(FILEFINDBUF4L)); 1144 1171 if (pci == NULL) { 1145 1172 priority_normal(); … … 1832 1859 VOID FreeCnrItemData(PCNRITEM pci) 1833 1860 { 1861 1834 1862 if (pci->pszSubject) { 1835 1863 if (pci->pszSubject != NullStr) … … 1837 1865 pci->pszSubject = NULL; // Catch illegal references 1838 1866 } 1839 1867 1840 1868 // 08 Sep 08 SHL Remove excess logic 1841 1869 if (pci->pszLongName) { … … 1844 1872 pci->pszLongName = NULL; // Catch illegal references 1845 1873 } 1846 1874 1847 1875 // Bypass free if pszDisplayName points into pszFileName buffer 1848 1876 // 05 Sep 08 SHL Correct pointer overlap compare logic … … 1853 1881 pci->pszDisplayName >= pci->pszFileName + _msize(pci->pszFileName)) 1854 1882 { 1855 free(pci->pszDisplayName);1883 free(pci->pszDisplayName); 1856 1884 } 1857 1885 } … … 1859 1887 } 1860 1888 1861 if (pci->pszFileName) { 1862 if (pci->pszFileName != NullStr) { 1889 #if 0 // 26 Sep 09 SHL debug dup free complaints 1890 if (!pci->pszFileName) 1891 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci); 1892 else { 1893 if (pci->pszFileName != NullStr) 1863 1894 free(pci->pszFileName); 1864 } 1865 pci->pszFileName = NULL; // Catch illegal references and dup free attempts 1866 } 1867 1868 // 26 Mar 14 JBS Twice on the longname? 1895 pci->pszFileName = NULL; // Catch illegal references 1896 } 1897 #else 1898 { 1899 #define HIST_COUNT 50 1900 static struct { 1901 PCNRITEM pci; 1902 PSZ pszFileName; 1903 } history[HIST_COUNT]; 1904 static volatile UINT iHistNdx; 1905 UINT i; 1906 1907 if (!pci->pszFileName) { 1908 // Looks like pci was already freed 1909 // Try to locate original file name in history buffer 1910 for (i = 0; i < HIST_COUNT && pci != history[i].pci; i++) { } // Scan 1911 if (i < HIST_COUNT) { 1912 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice, fileName was %.260s", 1913 pci, history[i].pszFileName); 1914 } else { 1915 Runtime_Error(pszSrcFile, __LINE__, "FreeCnrItemData attempting to free %p data twice", pci); 1916 } 1917 } 1918 else { 1919 PSZ psz; 1920 PSZ *ppsz; 1921 // Grab a history slot 1922 // This should work well enoungh to prevent MT/SMP conflicts 1923 for (;;) { 1924 i = iHistNdx; 1925 if (++i >= HIST_COUNT) 1926 i = 0; 1927 if (++iHistNdx >= HIST_COUNT) 1928 iHistNdx = 0; 1929 if (i == iHistNdx) break; 1930 } 1931 ppsz = &history[iHistNdx].pszFileName; 1932 psz = *ppsz; 1933 if (psz) 1934 free(psz); 1935 if (pci->pszFileName && pci->pszFileName != NullStr) 1936 *ppsz = strdup(pci->pszFileName); 1937 else 1938 *ppsz = NULL; 1939 history[iHistNdx].pci = pci; 1940 if (pci->pszFileName != NullStr) 1941 free(pci->pszFileName); 1942 pci->pszFileName = NULL; // Catch illegal references and dup free attempts 1943 } 1944 } 1945 1946 1947 #endif 1948 1869 1949 // 08 Sep 08 SHL Remove excess logic 1870 1950 if (pci->pszLongName) { … … 1943 2023 { 1944 2024 INT remaining = usCnt; 2025 BOOL bIdlePrioritySet = FALSE; 2026 // #define RCI_ITEMS_PER_TIMER_CHECK (10) 2027 // 10 seems a very conservative number 2028 // USHORT usTimerCheckCountdown = RCI_ITEMS_PER_TIMER_CHECK; 1945 2029 PCNRITEM pci; 1946 2030 ITIMER_DESC itdSleep = { 0 }; // 30 May 11 GKY … … 1966 2050 InitITimer(&itdSleep, 500); 1967 2051 while (pci) { 1968 FreeCnrItemData(pci); 2052 FreeCnrItemData(pci); 2053 pci = (PCNRITEM)pci->rc.preccNextRecord; 2054 if (!pci) 2055 break; 1969 2056 if (remaining && --remaining == 0) 1970 2057 break; 1971 pci = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, (MPARAM)pci, 1972 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1973 if (pci && !IdleIfNeeded(&itdSleep, 30)) { 1974 // Finishing in idle mode 1975 while (pci) { 1976 FreeCnrItemData(pci); 1977 if (remaining && --remaining == 0) 1978 break; 1979 pci = (PCNRITEM)WinSendMsg(hwnd, CM_QUERYRECORD, (MPARAM)pci, 1980 MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 1981 1982 } 1983 priority_normal(); 1984 break; 2058 if (!bIdlePrioritySet /* && --usTimerCheckCountdown == 0 */) { 2059 bIdlePrioritySet = !IdleIfNeeded(&itdSleep, 30); 2060 // usTimerCheckCountdown = RCI_ITEMS_PER_TIMER_CHECK; 1985 2061 } 1986 2062 } // while 2063 if (bIdlePrioritySet) 2064 priority_normal(); 2065 1987 2066 DosPostEventSem(CompactSem); 1988 2067 } 1989 2068 } 2069 2070 // DbgMsg(pszSrcFile, __LINE__, "RemoveCnrItems %p %u %s", pci, usCnt, pci->pszFileName); 1990 2071 1991 2072 if (remaining != - 1) { … … 1995 2076 } 1996 2077 } 2078 1997 2079 return remaining; 1998 2080 } -
trunk/dll/filter.c
r1797 r1836 24 24 30 Aug 14 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents 25 25 a trap when FM2 is shutdown while directory containers are still populating 26 14 Jun 15 GKY Changes to prevent trap in Filter 26 27 27 28 ***********************************************************************/ … … 83 84 CHAR *file; 84 85 85 DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);86 86 if (!mask) { 87 DosReleaseMutexSem(hmtxFiltering);88 87 return TRUE; 89 88 } // No mask data … … 94 93 if (!(*(pci->pszFileName + 3)) 95 94 || mask->fShowDirs && (pci->attrFile & FILE_DIRECTORY)) { 96 DosReleaseMutexSem(hmtxFiltering);97 95 return TRUE; 98 96 } … … 103 101 (~mask->attrFile & FILE_ARCHIVED && pci->attrFile & FILE_ARCHIVED) || 104 102 (~mask->attrFile & FILE_DIRECTORY && pci->attrFile & FILE_DIRECTORY)) { 105 DosReleaseMutexSem(hmtxFiltering);106 103 return FALSE; 107 104 } … … 112 109 (mask->antiattr & FILE_ARCHIVED && ~pci->attrFile & FILE_ARCHIVED) || 113 110 (mask->antiattr & FILE_DIRECTORY && ~pci->attrFile & FILE_DIRECTORY)) { 114 DosReleaseMutexSem(hmtxFiltering);115 111 return FALSE; 116 112 } 117 113 118 114 if (mask && !*mask->szMask) { 119 DosReleaseMutexSem(hmtxFiltering);120 115 return TRUE; 121 116 }// No masks … … 133 128 BOOL wild = wildcard(strchr(mask->szMask, '\\') || strchr(mask->szMask, ':') ? 134 129 pci->pszFileName : file, mask->szMask, FALSE); 135 DosReleaseMutexSem(hmtxFiltering);136 130 return wild; 137 131 } … … 139 133 // Have multiple mask strings 140 134 matched = FALSE; 141 for (x = 0; mask->pszMasks[x]; x++) {135 for (x = 0; x < 26 && mask->pszMasks[x]; x++) { 142 136 if (*mask->pszMasks[x]) { 143 137 if (*mask->pszMasks[x] != '/') { … … 164 158 } 165 159 } // for 166 DosReleaseMutexSem(hmtxFiltering);167 160 return matched; 168 161 }
Note:
See TracChangeset
for help on using the changeset viewer.
