From 127e23606ee190580d24c3ebdf6502089629215b Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Fri, 8 Oct 1999 04:55:37 +0000 Subject: [PATCH] add some bulletproofing. r=davidm git-svn-id: svn://10.0.0.236/trunk@50204 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpfe/appshell/src/nsFileLocations.cpp | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/mozilla/xpfe/appshell/src/nsFileLocations.cpp b/mozilla/xpfe/appshell/src/nsFileLocations.cpp index 3cbc9e0613c..319c0711baa 100644 --- a/mozilla/xpfe/appshell/src/nsFileLocations.cpp +++ b/mozilla/xpfe/appshell/src/nsFileLocations.cpp @@ -98,7 +98,14 @@ static PRBool GetProfileDirectory(nsFileSpec& outSpec) { // one profile exists: use that profile profileService->GetFirstProfile(&currProfileName); - profileService->GetProfileDir(currProfileName, &currProfileDirSpec); + if (currProfileName && (PL_strlen(currProfileName) > 0)) { + profileService->GetProfileDir(currProfileName, &currProfileDirSpec); + } + else { + // this should never happen + PR_FREEIF(currProfileName); + return PR_FALSE; + } } else { @@ -107,20 +114,27 @@ static PRBool GetProfileDirectory(nsFileSpec& outSpec) // (if we can't figure out what the last profile used was for some reason, // we'll pick the first one as returned from the registry query) profileService->GetCurrentProfile(&currProfileName); - if (currProfileName) + if (currProfileName && (PL_strlen(currProfileName) > 0)) { profileService->GetProfileDir(currProfileName, &currProfileDirSpec); + } else { profileService->GetFirstProfile(&currProfileName); - profileService->GetProfileDir(currProfileName, &currProfileDirSpec); + if (currProfileName && (PL_strlen(currProfileName) > 0)) { + profileService->GetProfileDir(currProfileName, &currProfileDirSpec); + } } } + if (!currProfileName || (PL_strlen(currProfileName) == 0)) { + // we don't have it, return false. + PR_FREEIF(currProfileName); + return PR_FALSE; + } #if defined(NS_DEBUG) - if (currProfileName) - { - printf("ProfileName : %s\n", currProfileName); - printf("ProfileDir : %s\n", currProfileDirSpec.GetNativePathCString()); - } + if (currProfileName) { + printf("ProfileName : %s\n", currProfileName); + printf("ProfileDir : %s\n", currProfileDirSpec.GetNativePathCString()); + } #endif /* NS_DEBUG */ PR_FREEIF(currProfileName); if (!currProfileDirSpec.Exists())