diff options
author | 2022-04-30 19:09:02 +1000 | |
---|---|---|
committer | 2022-04-30 19:09:02 +1000 | |
commit | 6d55afe0c57a0e5be2176e90cc6455864e2035b7 (patch) | |
tree | 7397aadefd8dfdd3bde9062f672b5d47585749ff | |
parent | f09cdb55d9ebcdcd514e6a0c67e25b954d278730 (diff) |
******fixed a resource leak
-rw-r--r-- | src/osd/winui/treeview.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/osd/winui/treeview.cpp b/src/osd/winui/treeview.cpp index c28ede76e1d..c0860dd11cf 100644 --- a/src/osd/winui/treeview.cpp +++ b/src/osd/winui/treeview.cpp @@ -1556,11 +1556,14 @@ void SelectTreeViewFolder(int folder_id) tvi.mask = TVIF_PARAM; res = TreeView_GetItem(hTreeView,&tvi); - if (((LPTREEFOLDER)tvi.lParam)->m_nFolderId == folder_id) + if (tvi.lParam) { - res = TreeView_SelectItem(hTreeView,tvi.hItem); - SetCurrentFolder((LPTREEFOLDER)tvi.lParam); - return; + if (((LPTREEFOLDER)tvi.lParam)->m_nFolderId == folder_id) + { + res = TreeView_SelectItem(hTreeView,tvi.hItem); + SetCurrentFolder((LPTREEFOLDER)tvi.lParam); + return; + } } hti_next = TreeView_GetChild(hTreeView,hti); @@ -2020,7 +2023,7 @@ static int InitExtraFolders(void) /* NPW 9-Feb-2003 - MSVC stat() doesn't like stat() called with an empty string */ if (!dir) - dir = "."; + return 0; //dir = "."; // Why create the directory if it doesn't exist, just return 0 folders. if (stat(dir, &stat_buffer) != 0) @@ -2030,14 +2033,16 @@ static int InitExtraFolders(void) chdir(dir); - long hLong = _findfirst("*", &files); - for (i = 0; i < MAX_EXTRA_FOLDERS; i++) ExtraFolderIcons[i] = NULL; numExtraIcons = 0; + intptr_t hLong = 0L; - while (!_findnext(hLong, &files)) + if ( (hLong = _findfirst("*.ini", &files)) == -1L ) + return 0; + + do { if ((files.attrib & _A_SUBDIR) == 0) { @@ -2112,9 +2117,10 @@ static int InitExtraFolders(void) } } } - } + } while( _findnext(hLong, &files) == 0); chdir(curdir); + _findclose(hLong); return count; } |