diff --git a/mailnews/compose/src/nsMsgSend.cpp b/mailnews/compose/src/nsMsgSend.cpp index f03155c5b012..6d14d0566908 100644 --- a/mailnews/compose/src/nsMsgSend.cpp +++ b/mailnews/compose/src/nsMsgSend.cpp @@ -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, diff --git a/mailnews/db/msgdb/src/nsMsgOfflineImapOperation.cpp b/mailnews/db/msgdb/src/nsMsgOfflineImapOperation.cpp index 1eaa1a0ca624..087087688841 100644 --- a/mailnews/db/msgdb/src/nsMsgOfflineImapOperation.cpp +++ b/mailnews/db/msgdb/src/nsMsgOfflineImapOperation.cpp @@ -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); diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index bcfa5159b40b..b7ece708abf5 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -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 msgSupports; nsCOMPtr 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); diff --git a/mailnews/local/src/nsMailboxUrl.cpp b/mailnews/local/src/nsMailboxUrl.cpp index 3e6b68cf726c..f293acf1c177 100644 --- a/mailnews/local/src/nsMailboxUrl.cpp +++ b/mailnews/local/src/nsMailboxUrl.cpp @@ -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; } diff --git a/netwerk/protocol/http/src/nsHttpHandler.cpp b/netwerk/protocol/http/src/nsHttpHandler.cpp index ad0e84f61665..7ab468ee739c 100644 --- a/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -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; } diff --git a/netwerk/protocol/http/src/nsHttpRequestHead.h b/netwerk/protocol/http/src/nsHttpRequestHead.h index 81f7d3cceaa9..ac9331d15284 100644 --- a/netwerk/protocol/http/src/nsHttpRequestHead.h +++ b/netwerk/protocol/http/src/nsHttpRequestHead.h @@ -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; } diff --git a/netwerk/protocol/http/src/nsHttpResponseHead.h b/netwerk/protocol/http/src/nsHttpResponseHead.h index 458efcb96222..e898272a1ccc 100644 --- a/netwerk/protocol/http/src/nsHttpResponseHead.h +++ b/netwerk/protocol/http/src/nsHttpResponseHead.h @@ -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, diff --git a/rdf/base/src/nsRDFService.cpp b/rdf/base/src/nsRDFService.cpp index 99913d6ee11e..e932e5f1ec5a 100644 --- a/rdf/base/src/nsRDFService.cpp +++ b/rdf/base/src/nsRDFService.cpp @@ -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; diff --git a/xpfe/components/directory/nsDirectoryViewer.cpp b/xpfe/components/directory/nsDirectoryViewer.cpp index b27869ab6065..7e5fcb9b30e5 100644 --- a/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/xpfe/components/directory/nsDirectoryViewer.cpp @@ -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);