From 4a8e19199a62ba935614e1bc2502a84e8bd95073 Mon Sep 17 00:00:00 2001 From: kichik Date: Fri, 6 Feb 2004 22:37:46 +0000 Subject: [PATCH] only free the PIDL in DirProc, don't parse it too so g_tmp gets overwritten with the entire path instaed of just the display name git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3472 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/exehead/Ui.c | 12 ++++++------ Source/exehead/util.c | 9 ++++----- Source/exehead/util.h | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 103d6bc5..701d17e0 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -855,17 +855,17 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar idlist = SHBrowseForFolder(&bi); if (idlist) { - // Get and free idlist - my_PIDL2Path(g_tmp, idlist); + // free idlist + FreePIDL(idlist); if (g_header->install_directory_auto_append) { - const char *post_str=ps_tmpbuf; + const char *post_str = ps_tmpbuf; GetNSISStringTT(g_header->install_directory_auto_append); - // name gives just the folder name - if (lstrcmpi(post_str,g_tmp)) + // display name gives just the folder name + if (lstrcmpi(post_str, g_tmp)) { - lstrcat(addtrailingslash(dir),post_str); + lstrcat(addtrailingslash(dir), post_str); } } diff --git a/Source/exehead/util.c b/Source/exehead/util.c index c83f2a37..3972bcd2 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -27,18 +27,15 @@ NSIS_STRING g_usrvars[1]; #define SECTION_VARS_RWD "/section:" ## VARS_SECTION_NAME ## ",rwd" #pragma comment(linker, SECTION_VARS_RWD) -int NSISCALL my_PIDL2Path(char *out, LPITEMIDLIST idl) +void NSISCALL FreePIDL(LPITEMIDLIST idl) { - int Res; IMalloc *m; SHGetMalloc(&m); - Res = SHGetPathFromIDList(idl, out); if (m) { m->lpVtbl->Free(m, idl); m->lpVtbl->Release(m); } - return Res; } HANDLE NSISCALL myCreateProcess(char *cmd, char *dir) @@ -537,7 +534,9 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab) { if (!SHGetSpecialFolderLocation(g_hwnd, fldrs[x], &idl)) { - if (my_PIDL2Path(out, idl)) + BOOL res = SHGetPathFromIDList(idl, out); + FreePIDL(idl); + if (res) { break; } diff --git a/Source/exehead/util.h b/Source/exehead/util.h index 48e5094a..4db11c07 100644 --- a/Source/exehead/util.h +++ b/Source/exehead/util.h @@ -14,7 +14,7 @@ int NSISCALL mystrlen(const char *in); char * NSISCALL mystrstr(char *a, char *b); WIN32_FIND_DATA * NSISCALL file_exists(char *buf); char * NSISCALL my_GetTempFileName(char *buf, const char *dir); -int NSISCALL my_PIDL2Path(char *out, LPITEMIDLIST idl); +void NSISCALL FreePIDL(LPITEMIDLIST idl); //BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val); #define my_SetWindowText SetWindowText