diff options
author | Tim Angus <tim@ngus.net> | 2013-04-09 21:41:51 +0100 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-05-03 16:10:49 +0100 |
commit | 41db0dd2e8c3ceabab3211f2708a4cadfb38ff36 (patch) | |
tree | 3747657bba1f73b1f7c623c4ae868bf1176119d3 | |
parent | caf9c3c4feb6e65963e82a6b4c87895732de79f2 (diff) |
Fix shfolder.dll not getting freed
-rw-r--r-- | src/sys/sys_win32.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/sys/sys_win32.c b/src/sys/sys_win32.c index e3a550d7..abb38b78 100644 --- a/src/sys/sys_win32.c +++ b/src/sys/sys_win32.c @@ -91,15 +91,15 @@ char *Sys_DefaultHomePath( void ) TCHAR szPath[MAX_PATH]; FARPROC qSHGetFolderPath; HMODULE shfolder = LoadLibrary("shfolder.dll"); - - if(!*homePath && com_homepath) + + if(shfolder == NULL) { - if(shfolder == NULL) - { - Com_Printf("Unable to load SHFolder.dll\n"); - return NULL; - } + Com_Printf("Unable to load SHFolder.dll\n"); + return NULL; + } + if(!*homePath && com_homepath) + { qSHGetFolderPath = GetProcAddress(shfolder, "SHGetFolderPathA"); if(qSHGetFolderPath == NULL) { @@ -115,11 +115,16 @@ char *Sys_DefaultHomePath( void ) FreeLibrary(shfolder); return NULL; } - Q_strncpyz( homePath, szPath, sizeof( homePath ) ); - Q_strcat( homePath, sizeof( homePath ), "\\" HOMEPATH_NAME_WIN ); - FreeLibrary(shfolder); + + Com_sprintf(homePath, sizeof(homePath), "%s%c", szPath, PATH_SEP); + + if(com_homepath->string[0]) + Q_strcat(homePath, sizeof(homePath), com_homepath->string); + else + Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_WIN); } + FreeLibrary(shfolder); return homePath; } |