From e933fee4bba8d484f36956845659ccbfd2ead45c Mon Sep 17 00:00:00 2001 From: "mscott@netscape.com" Date: Fri, 9 Jul 1999 23:07:50 +0000 Subject: [PATCH] NECKO change only --> if we failed to get a content type we would crash because we were executing code even if the return value was failure that dependend on the content type ptr being valid. --- htmlparser/src/nsParser.cpp | 13 ++++++++----- parser/htmlparser/src/nsParser.cpp | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/htmlparser/src/nsParser.cpp b/htmlparser/src/nsParser.cpp index 4cd2eef67f74..1604cac17ef8 100644 --- a/htmlparser/src/nsParser.cpp +++ b/htmlparser/src/nsParser.cpp @@ -1060,13 +1060,16 @@ nsresult nsParser::OnStartRequest(nsIURI* aURL, const char *aSourceType) mParserContext->mDTD=0; #ifdef NECKO nsresult rv; - char* contentType; + char* contentType = nsnull; rv = channel->GetContentType(&contentType); - if (NS_FAILED(rv)) { - NS_ASSERTION(contentType, "parser needs a content type to find a dtd"); + if (NS_SUCCEEDED(rv)) + { + mParserContext->mSourceType = contentType; + nsCRT::free(contentType); } - mParserContext->mSourceType = contentType; - nsCRT::free(contentType); + else + NS_ASSERTION(contentType, "parser needs a content type to find a dtd"); + #else mParserContext->mSourceType=aSourceType; #endif diff --git a/parser/htmlparser/src/nsParser.cpp b/parser/htmlparser/src/nsParser.cpp index 4cd2eef67f74..1604cac17ef8 100644 --- a/parser/htmlparser/src/nsParser.cpp +++ b/parser/htmlparser/src/nsParser.cpp @@ -1060,13 +1060,16 @@ nsresult nsParser::OnStartRequest(nsIURI* aURL, const char *aSourceType) mParserContext->mDTD=0; #ifdef NECKO nsresult rv; - char* contentType; + char* contentType = nsnull; rv = channel->GetContentType(&contentType); - if (NS_FAILED(rv)) { - NS_ASSERTION(contentType, "parser needs a content type to find a dtd"); + if (NS_SUCCEEDED(rv)) + { + mParserContext->mSourceType = contentType; + nsCRT::free(contentType); } - mParserContext->mSourceType = contentType; - nsCRT::free(contentType); + else + NS_ASSERTION(contentType, "parser needs a content type to find a dtd"); + #else mParserContext->mSourceType=aSourceType; #endif