bug #85271: avoid regressions by re-creating the old behavior near |nsCRT::strdup|, see bug #86316

This commit is contained in:
scc%mozilla.org 2001-06-18 03:50:12 +00:00
parent ad4e9b47c8
commit 1f69171c8f
9 changed files with 24 additions and 19 deletions

View File

@ -1133,7 +1133,10 @@ nsMsgComposeAndSend::PreProcessPart(nsMsgAttachmentHandler *ma,
nsXPIDLCString turl;
if (!ma->mURL)
turl.Adopt(nsCRT::strdup(ma->m_uri));
{
if (ma->m_uri)
turl.Adopt(nsCRT::strdup(ma->m_uri));
}
else
ma->mURL->GetSpec(getter_Copies(turl));
hdrs = mime_generate_attachment_headers (ma->m_type, ma->m_encoding,

View File

@ -152,7 +152,7 @@ NS_IMETHODIMP nsMsgOfflineImapOperation::GetDestinationFolderURI(char * *aDestin
NS_IMETHODIMP nsMsgOfflineImapOperation::SetDestinationFolderURI(const char * aDestinationFolderURI)
{
m_moveDestination.Adopt(nsCRT::strdup(aDestinationFolderURI));
m_moveDestination.Adopt(aDestinationFolderURI ? nsCRT::strdup(aDestinationFolderURI) : 0);
return m_mdb->SetProperty(m_mdbRow, PROP_MOVE_DEST_FOLDER_URI, aDestinationFolderURI);
}
@ -167,7 +167,7 @@ NS_IMETHODIMP nsMsgOfflineImapOperation::GetSourceFolderURI(char * *aSourceFolde
NS_IMETHODIMP nsMsgOfflineImapOperation::SetSourceFolderURI(const char * aSourceFolderURI)
{
m_sourceFolder.Adopt(nsCRT::strdup(aSourceFolderURI));
m_sourceFolder.Adopt(aSourceFolderURI ? nsCRT::strdup(aSourceFolderURI) : 0);
SetOperation(kMoveResult);
return m_mdb->SetProperty(m_mdbRow, PROP_SRC_FOLDER_URI, aSourceFolderURI);

View File

@ -4742,7 +4742,8 @@ nsresult nsImapMailFolder::CopyMessagesOffline(nsIMsgFolder* srcFolder,
nsXPIDLCString sourceFolderURI;
srcFolder->GetURI(getter_Copies(sourceFolderURI));
nsXPIDLCString originalSrcFolderURI;
originalSrcFolderURI.Adopt(nsCRT::strdup(sourceFolderURI.get()));
if (sourceFolderURI.get())
originalSrcFolderURI.Adopt(nsCRT::strdup(sourceFolderURI.get()));
nsCOMPtr<nsISupports> msgSupports;
nsCOMPtr<nsIMsgDBHdr> message;
@ -4782,7 +4783,7 @@ nsresult nsImapMailFolder::CopyMessagesOffline(nsIMsgFolder* srcFolder,
srcFolder->GetURI(getter_Copies(srcFolderURI));
sourceOp->GetSourceFolderURI(getter_Copies(originalString));
sourceOp->GetMessageKey(&originalKey);
originalSrcFolderURI.Adopt(nsCRT::strdup(originalString.get()));
originalSrcFolderURI.Adopt(originalString.get() ? nsCRT::strdup(originalString.get()) : 0);
if (isMove)
sourceMailDB->RemoveOfflineOp(sourceOp);

View File

@ -304,7 +304,7 @@ nsMailboxUrl::GetOriginalSpec(char **aSpec)
NS_IMETHODIMP
nsMailboxUrl::SetOriginalSpec(const char *aSpec)
{
m_originalSpec.Adopt(nsCRT::strdup(aSpec));
m_originalSpec.Adopt(aSpec ? nsCRT::strdup(aSpec) : 0);
return NS_OK;
}

View File

@ -1597,7 +1597,7 @@ nsHttpHandler::GetVendor(char **aVendor)
NS_IMETHODIMP
nsHttpHandler::SetVendor(const char *aVendor)
{
mVendor.Adopt(nsCRT::strdup(aVendor));
mVendor.Adopt(aVendor ? nsCRT::strdup(aVendor) : 0);
mUserAgentIsDirty = PR_TRUE;
return NS_OK;
}
@ -1610,7 +1610,7 @@ nsHttpHandler::GetVendorSub(char **aVendorSub)
NS_IMETHODIMP
nsHttpHandler::SetVendorSub(const char *aVendorSub)
{
mVendorSub.Adopt(nsCRT::strdup(aVendorSub));
mVendorSub.Adopt(aVendorSub ? nsCRT::strdup(aVendorSub) : 0);
mUserAgentIsDirty = PR_TRUE;
return NS_OK;
}
@ -1623,7 +1623,7 @@ nsHttpHandler::GetVendorComment(char **aVendorComment)
NS_IMETHODIMP
nsHttpHandler::SetVendorComment(const char *aVendorComment)
{
mVendorComment.Adopt(nsCRT::strdup(aVendorComment));
mVendorComment.Adopt(aVendorComment ? nsCRT::strdup(aVendorComment) : 0);
mUserAgentIsDirty = PR_TRUE;
return NS_OK;
}
@ -1636,7 +1636,7 @@ nsHttpHandler::GetProduct(char **aProduct)
NS_IMETHODIMP
nsHttpHandler::SetProduct(const char *aProduct)
{
mProduct.Adopt(nsCRT::strdup(aProduct));
mProduct.Adopt(aProduct ? nsCRT::strdup(aProduct) : 0);
mUserAgentIsDirty = PR_TRUE;
return NS_OK;
}
@ -1649,7 +1649,7 @@ nsHttpHandler::GetProductSub(char **aProductSub)
NS_IMETHODIMP
nsHttpHandler::SetProductSub(const char *aProductSub)
{
mProductSub.Adopt(nsCRT::strdup(aProductSub));
mProductSub.Adopt(aProductSub ? nsCRT::strdup(aProductSub) : 0);
mUserAgentIsDirty = PR_TRUE;
return NS_OK;
}
@ -1662,7 +1662,7 @@ nsHttpHandler::GetProductComment(char **aProductComment)
NS_IMETHODIMP
nsHttpHandler::SetProductComment(const char *aProductComment)
{
mProductComment.Adopt(nsCRT::strdup(aProductComment));
mProductComment.Adopt(aProductComment ? nsCRT::strdup(aProductComment) : 0);
mUserAgentIsDirty = PR_TRUE;
return NS_OK;
}
@ -1687,7 +1687,7 @@ nsHttpHandler::GetLanguage(char **aLanguage)
NS_IMETHODIMP
nsHttpHandler::SetLanguage(const char *aLanguage)
{
mLanguage.Adopt(nsCRT::strdup(aLanguage));
mLanguage.Adopt(aLanguage ? nsCRT::strdup(aLanguage) : 0);
mUserAgentIsDirty = PR_TRUE;
return NS_OK;
}
@ -1700,7 +1700,7 @@ nsHttpHandler::GetMisc(char **aMisc)
NS_IMETHODIMP
nsHttpHandler::SetMisc(const char *aMisc)
{
mMisc.Adopt(nsCRT::strdup(aMisc));
mMisc.Adopt(aMisc ? nsCRT::strdup(aMisc) : 0);
mUserAgentIsDirty = PR_TRUE;
return NS_OK;
}

View File

@ -41,7 +41,7 @@ public:
void SetMethod(nsHttpAtom method) { mMethod = method; }
void SetVersion(nsHttpVersion version) { mVersion = version; }
void SetRequestURI(const char *s) { mRequestURI.Adopt(nsCRT::strdup(s)); }
void SetRequestURI(const char *s) { mRequestURI.Adopt(s ? nsCRT::strdup(s) : 0); }
nsHttpHeaderArray &Headers() { return mHeaders; }
nsHttpAtom Method() { return mMethod; }

View File

@ -54,7 +54,7 @@ public:
nsresult GetHeader(nsHttpAtom h, char **v) { return mHeaders.GetHeader(h, v); }
void ClearHeaders() { mHeaders.Clear(); }
void SetContentType(const char *s) { mContentType.Adopt(nsCRT::strdup(s)); }
void SetContentType(const char *s) { mContentType.Adopt(s ? nsCRT::strdup(s) : 0); }
void SetContentLength(PRInt32 len) { mContentLength = len; }
// write out the response status line and headers as a single text block,

View File

@ -304,7 +304,8 @@ LiteralImpl::GetValue(PRUnichar* *value)
if (! value)
return NS_ERROR_NULL_POINTER;
*value = nsCRT::strdup(GetValue());
const PRUnichar *temp = GetValue();
*value = temp? nsCRT::strdup(temp) : 0;
return NS_OK;
}
@ -1288,7 +1289,7 @@ RDFServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral, PRBool aReplace)
#ifdef REUSE_LITERAL_VALUE_AS_KEY
PL_HashTableAdd(mLiterals, value, aLiteral);
#else
const PRUnichar* key = nsCRT::strdup(value.get());
const PRUnichar* key = value.get() ? nsCRT::strdup(value.get()) : 0;
if (! key)
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -1295,7 +1295,7 @@ void nsHTTPIndex::GetDestination(nsIRDFResource* r, nsXPIDLCString& dest) {
if (!url) {
const char* temp;
r->GetValueConst(&temp);
dest.Adopt(nsCRT::strdup(temp));
dest.Adopt(temp ? nsCRT::strdup(temp) : 0);
} else {
const PRUnichar* uri;
url->GetValueConst(&uri);