Changeset 1102

Show
Ignore:
Timestamp:
08/02/08 22:29:35 (5 weeks ago)
Author:
gyoung
Message:

Make the variable passed to treecnr UM_RESCAN a pointer to a temp variable every where to avoid freeing pci->pszFileName or dcd->directory early

Location:
trunk/dll
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r1084 r1102  
    4646  20 Jul 08 GKY Add save/append filename to clipboard. 
    4747                Change menu wording to make these easier to find 
     48  02 Aug 08 GKY Always pass temp variable point to treecnr UM_SHOWME to avoid 
     49                freeing dcd->directory early 
    4850 
    4951***********************************************************************/ 
     
    781783      } 
    782784      if (fSwitchTree && hwndTree) { 
     785        PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__); 
     786 
    783787        if (hwndMain) { 
    784           if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame) 
    785             WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID); 
    786         } 
    787         else 
    788           WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID); 
     788          if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame && pszTempDir) 
     789            if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID)) 
     790              free(pszTempDir); 
     791        } 
     792        else { 
     793          if (pszTempDir) 
     794            if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID)) 
     795              free(pszTempDir); 
     796        } 
    789797      } 
    790798      dcd->firsttree = FALSE; 
     
    13341342      LastDir = hwnd; 
    13351343      PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID); 
    1336       if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory) 
    1337         WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID); 
     1344      if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory) { 
     1345        PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__); 
     1346 
     1347        if (pszTempDir) { 
     1348          if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), MPVOID)) 
     1349            free(pszTempDir); 
     1350        } 
     1351      } 
    13381352    } 
    13391353    break; 
     
    18431857 
    18441858      case IDM_FINDINTREE: 
    1845         if (hwndTree) 
    1846           WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), 
    1847                      MPFROMLONG(1L)); 
     1859        if (hwndTree) { 
     1860          PSZ pszTempDir = xstrdup(dcd->directory, pszSrcFile, __LINE__); 
     1861 
     1862          if (pszTempDir) { 
     1863            if (!WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(pszTempDir), 
     1864                            MPFROMLONG(1L))) 
     1865              free(pszTempDir); 
     1866          } 
     1867        } 
    18481868        break; 
    18491869 
  • trunk/dll/treecnr.c

    r1079 r1102  
    4646  15 Feb 08 SHL Sync with settings menu rework 
    4747  15 Feb 08 SHL Avoid death if tree container 0 width 
     48  19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory 
     49  02 Aug 08 GKY Always pass temp variable point to UM_SHOWME to avoid freeing pci->pszFileName early 
    4850 
    4951***********************************************************************/ 
     
    674676      if (cnri.cRecords) { 
    675677        sprintf(s, GetPString(IDS_NUMDRIVESTEXT), cnri.cRecords); 
    676         if (pci) { 
     678        if (pci && pci->pszFileName) { 
    677679          if (!(driveflags[toupper(*pci->pszFileName) - 'A'] & 
    678680                DRIVE_REMOVABLE) || 
     
    23542356      case IDM_FINDINTREE: 
    23552357        { 
    2356           CHAR dir[CCHMAXPATH]; 
     2358          PSZ pszTempDir; 
    23572359          PCNRITEM pci; 
    23582360 
    23592361          pci = (PCNRITEM) CurrentRecord(hwnd); 
    23602362          if (pci && (INT) pci != -1) { 
    2361             strcpy(dir, pci->pszFileName); 
    2362             MakeValidDir(dir); 
     2363            pszTempDir = xstrdup(pci->pszFileName, pszSrcFile, __LINE__); 
     2364            if (pszTempDir) 
     2365              MakeValidDir(pszTempDir); 
    23632366          } 
    23642367          else 
    2365             save_dir2(dir); 
    2366           if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent, 
    2367                         WalkAllDlgProc, 
    2368                         FM3ModHandle, WALK_FRAME, MPFROMP(dir)) && *dir) 
    2369             WinSendMsg(hwnd, UM_SHOWME, MPFROMP(dir), MPFROMLONG(1)); 
     2368            pszTempDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__); 
     2369          if (pszTempDir) { 
     2370            if (WinDlgBox(HWND_DESKTOP, dcd->hwndParent, 
     2371                          WalkAllDlgProc, 
     2372                          FM3ModHandle, WALK_FRAME, MPFROMP(pszTempDir))) { 
     2373              if (!WinSendMsg(hwnd, UM_SHOWME, MPFROMP(pszTempDir), MPFROMLONG(1))) 
     2374                free(pszTempDir); 
     2375            } 
     2376            else 
     2377              free(pszTempDir); 
     2378          } 
    23702379        } 
    23712380        break; 
     
    24402449          } 
    24412450          else 
    2442             save_dir2(newpath); 
     2451            strcpy(newpath, pFM2SaveDirectory); 
    24432452          if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkAllDlgProc, 
    24442453                         FM3ModHandle, WALK_FRAME,