diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 29d3f76107b..51eb529bdf6 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -2269,13 +2269,14 @@ nsresult nsWebShell::CheckForTrailingSlash(nsIURL* aURL) aURL->GetSpec(&spec); nsString* newURL = (nsString*) new nsString(spec); - if (newURL->Last() == '/' && !historyURL->Equals(*newURL)) { + if (newURL && newURL->Last() == '/' && !historyURL->Equals(*newURL)) { // Replace the top most history entry with the new url if (nsnull != historyURL) { delete historyURL; } mHistory.ReplaceElementAt(newURL, mHistoryIndex); - } + } else + delete newURL; return NS_OK; } diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 29d3f76107b..51eb529bdf6 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -2269,13 +2269,14 @@ nsresult nsWebShell::CheckForTrailingSlash(nsIURL* aURL) aURL->GetSpec(&spec); nsString* newURL = (nsString*) new nsString(spec); - if (newURL->Last() == '/' && !historyURL->Equals(*newURL)) { + if (newURL && newURL->Last() == '/' && !historyURL->Equals(*newURL)) { // Replace the top most history entry with the new url if (nsnull != historyURL) { delete historyURL; } mHistory.ReplaceElementAt(newURL, mHistoryIndex); - } + } else + delete newURL; return NS_OK; }