From 41db0dd2e8c3ceabab3211f2708a4cadfb38ff36 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Tue, 9 Apr 2013 21:41:51 +0100 Subject: Fix shfolder.dll not getting freed --- src/sys/sys_win32.c | 25 +++++++++++++++---------- 1 file 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; } -- cgit