diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 82dd51be0..1a1db8fb3 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1390,8 +1390,8 @@ static const char *searchWad(const char *searchDir) #define CHECKWADPATH(ret) \ do { \ - I_OutputMsg(",%s", returnWadPath); \ - if (isWadPathOk(returnWadPath)) \ + I_OutputMsg(",%s", ret); \ + if (isWadPathOk(ret)) \ return ret; \ } while (0) @@ -1416,7 +1416,9 @@ static const char *locateWad(void) #ifndef NOCWD // examine current dir strcpy(returnWadPath, "."); - CHECKWADPATH(NULL); + I_OutputMsg(",%s", returnWadPath); + if (isWadPathOk(returnWadPath)) + return NULL; #endif #ifdef __APPLE__ @@ -1433,13 +1435,13 @@ static const char *locateWad(void) #ifndef NOHOME // find in $HOME - I_OutputMsg(",HOME/" DEFAULTDIR); if ((envstr = I_GetEnv("HOME")) != NULL) { - char *tmp = malloc(strlen(envstr) + sizeof(DEFAULTDIR)); + char *tmp = malloc(strlen(envstr) + 1 + sizeof(DEFAULTDIR)); strcpy(tmp, envstr); + strcat(tmp, "/"); strcat(tmp, DEFAULTDIR); - SEARCHWAD(envstr); + CHECKWADPATH(tmp); free(tmp); } #endif diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index e28fbd34a..9fe50a6a2 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3003,8 +3003,8 @@ static const char *searchWad(const char *searchDir) #define CHECKWADPATH(ret) \ do { \ - I_OutputMsg(",%s", returnWadPath); \ - if (isWadPathOk(returnWadPath)) \ + I_OutputMsg(",%s", ret); \ + if (isWadPathOk(ret)) \ return ret; \ } while (0) @@ -3033,7 +3033,9 @@ static const char *locateWad(void) #ifndef NOCWD // examine current dir strcpy(returnWadPath, "."); - CHECKWADPATH(NULL); + I_OutputMsg(",%s", returnWadPath); + if (isWadPathOk(returnWadPath)) + return NULL; #endif #ifdef __APPLE__ @@ -3053,10 +3055,11 @@ static const char *locateWad(void) I_OutputMsg(",HOME/" DEFAULTDIR); if ((envstr = I_GetEnv("HOME")) != NULL) { - char *tmp = malloc(strlen(envstr) + sizeof(DEFAULTDIR)); + char *tmp = malloc(strlen(envstr) + 1 + sizeof(DEFAULTDIR)); strcpy(tmp, envstr); + strcat(tmp, "/"); strcat(tmp, DEFAULTDIR); - SEARCHWAD(envstr); + CHECKWADPATH(tmp); free(tmp); } #endif