From 7faf639ae44c834905c6dc2f2fefb4160a9d4c1c Mon Sep 17 00:00:00 2001 From: "naving%netscape.com" Date: Sun, 25 Nov 2001 03:02:24 +0000 Subject: [PATCH] 111371 r/sr=bienvenu fix char* leaks when reading filenames from disk. --- mailnews/local/src/nsLocalMailFolder.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp index f4afdc6989cf..6f4aa1586a54 100644 --- a/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mailnews/local/src/nsLocalMailFolder.cpp @@ -234,7 +234,10 @@ nsMsgLocalMailFolder::CreateSubFolders(nsFileSpec &path) for (nsDirectoryIterator dir(path, PR_FALSE); dir.Exists(); dir++) { nsFileSpec currentFolderPath = dir.Spec(); - nsMsgGetNativePathString(currentFolderPath.GetLeafName(),currentFolderNameStr); + char *leafName = currentFolderPath.GetLeafName(); + nsMsgGetNativePathString(leafName, currentFolderNameStr); + PR_FREEIF(leafName); + if (nsShouldIgnoreFile(currentFolderNameStr)) continue; @@ -771,7 +774,11 @@ nsMsgLocalMailFolder::CheckIfFolderExists(const PRUnichar *folderName, nsFileSpe for (nsDirectoryIterator dir(path, PR_FALSE); dir.Exists(); dir++) { nsFileSpec currentFolderPath = dir.Spec(); - nsMsgGetNativePathString(currentFolderPath.GetLeafName(),leafName); + + char *leaf = currentFolderPath.GetLeafName(); + nsMsgGetNativePathString(leaf,leafName); + PR_FREEIF(leaf); + if (!leafName.IsEmpty() && Compare(nsDependentString(folderName), leafName, nsCaseInsensitiveStringComparator()) == 0)