mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 14:30:43 +00:00
fix for #110698. fix assertions cause by calling NS_ConvertUTF8toUCS2() with null.
fix the code to not call MIME_DecodeMimeHeader() and NS_ConvertUTF8toUCS2() when the header is null. r/sr=bienvenu
This commit is contained in:
parent
e34d9b0a63
commit
33d8df3f0b
@ -298,77 +298,106 @@ CreateCompositionFields(const char *from,
|
|||||||
nsIMsgCompFields **_retval)
|
nsIMsgCompFields **_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
NS_ENSURE_ARG_POINTER(_retval);
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
*_retval = nsnull;
|
*_retval = nsnull;
|
||||||
|
|
||||||
char *val;
|
|
||||||
nsCOMPtr<nsIMsgCompFields> cFields = do_CreateInstance(NS_MSGCOMPFIELDS_CONTRACTID, &rv);
|
nsCOMPtr<nsIMsgCompFields> cFields = do_CreateInstance(NS_MSGCOMPFIELDS_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
NS_ENSURE_TRUE(cFields, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(cFields, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
// Now set all of the passed in stuff...
|
// Now set all of the passed in stuff...
|
||||||
cFields->SetCharacterSet(charset);
|
cFields->SetCharacterSet(charset);
|
||||||
|
|
||||||
val = MIME_DecodeMimeHeader(from, charset, PR_FALSE, PR_TRUE);
|
char *val;
|
||||||
cFields->SetFrom(NS_ConvertUTF8toUCS2(val ? val : from).get());
|
|
||||||
PR_FREEIF(val);
|
if (from) {
|
||||||
|
val = MIME_DecodeMimeHeader(from, charset, PR_FALSE, PR_TRUE);
|
||||||
val = MIME_DecodeMimeHeader(subject, charset, PR_FALSE, PR_TRUE);
|
cFields->SetFrom(NS_ConvertUTF8toUCS2(val ? val : from).get());
|
||||||
cFields->SetSubject(NS_ConvertUTF8toUCS2(val ? val : subject).get());
|
PR_FREEIF(val);
|
||||||
PR_FREEIF(val);
|
}
|
||||||
|
|
||||||
val = MIME_DecodeMimeHeader(reply_to, charset, PR_FALSE, PR_TRUE);
|
if (subject) {
|
||||||
cFields->SetReplyTo(NS_ConvertUTF8toUCS2(val ? val : reply_to).get());
|
val = MIME_DecodeMimeHeader(subject, charset, PR_FALSE, PR_TRUE);
|
||||||
PR_FREEIF(val);
|
cFields->SetSubject(NS_ConvertUTF8toUCS2(val ? val : subject).get());
|
||||||
|
PR_FREEIF(val);
|
||||||
val = MIME_DecodeMimeHeader(to, charset, PR_FALSE, PR_TRUE);
|
}
|
||||||
cFields->SetTo(NS_ConvertUTF8toUCS2(val ? val : to).get());
|
|
||||||
PR_FREEIF(val);
|
if (reply_to) {
|
||||||
|
val = MIME_DecodeMimeHeader(reply_to, charset, PR_FALSE, PR_TRUE);
|
||||||
val = MIME_DecodeMimeHeader(cc, charset, PR_FALSE, PR_TRUE);
|
cFields->SetReplyTo(NS_ConvertUTF8toUCS2(val ? val : reply_to).get());
|
||||||
cFields->SetCc(NS_ConvertUTF8toUCS2(val ? val : cc).get());
|
PR_FREEIF(val);
|
||||||
PR_FREEIF(val);
|
}
|
||||||
|
|
||||||
val = MIME_DecodeMimeHeader(bcc, charset, PR_FALSE, PR_TRUE);
|
if (to) {
|
||||||
cFields->SetBcc(NS_ConvertUTF8toUCS2(val ? val : bcc).get());
|
val = MIME_DecodeMimeHeader(to, charset, PR_FALSE, PR_TRUE);
|
||||||
PR_FREEIF(val);
|
cFields->SetTo(NS_ConvertUTF8toUCS2(val ? val : to).get());
|
||||||
|
PR_FREEIF(val);
|
||||||
val = MIME_DecodeMimeHeader(fcc, charset, PR_FALSE, PR_TRUE);
|
}
|
||||||
cFields->SetFcc(NS_ConvertUTF8toUCS2(val ? val : fcc).get());
|
|
||||||
PR_FREEIF(val);
|
if (cc) {
|
||||||
|
val = MIME_DecodeMimeHeader(cc, charset, PR_FALSE, PR_TRUE);
|
||||||
val = MIME_DecodeMimeHeader(newsgroups, charset, PR_FALSE, PR_TRUE);
|
cFields->SetCc(NS_ConvertUTF8toUCS2(val ? val : cc).get());
|
||||||
cFields->SetNewsgroups(val ? val : newsgroups);
|
PR_FREEIF(val);
|
||||||
PR_FREEIF(val);
|
}
|
||||||
|
|
||||||
val = MIME_DecodeMimeHeader(followup_to, charset, PR_FALSE, PR_TRUE);
|
if (bcc) {
|
||||||
cFields->SetFollowupTo(val ? val : followup_to);
|
val = MIME_DecodeMimeHeader(bcc, charset, PR_FALSE, PR_TRUE);
|
||||||
PR_FREEIF(val);
|
cFields->SetBcc(NS_ConvertUTF8toUCS2(val ? val : bcc).get());
|
||||||
|
PR_FREEIF(val);
|
||||||
val = MIME_DecodeMimeHeader(organization, charset, PR_FALSE, PR_TRUE);
|
}
|
||||||
cFields->SetOrganization(NS_ConvertUTF8toUCS2(val ? val : organization).get());
|
|
||||||
PR_FREEIF(val);
|
if (fcc) {
|
||||||
|
val = MIME_DecodeMimeHeader(fcc, charset, PR_FALSE, PR_TRUE);
|
||||||
val = MIME_DecodeMimeHeader(references, charset, PR_FALSE, PR_TRUE);
|
cFields->SetFcc(NS_ConvertUTF8toUCS2(val ? val : fcc).get());
|
||||||
cFields->SetReferences(val ? val : references);
|
PR_FREEIF(val);
|
||||||
PR_FREEIF(val);
|
}
|
||||||
|
|
||||||
val = MIME_DecodeMimeHeader(other_random_headers, charset, PR_FALSE, PR_TRUE);
|
if (newsgroups) {
|
||||||
cFields->SetOtherRandomHeaders(NS_ConvertUTF8toUCS2(val ? val : other_random_headers).get());
|
val = MIME_DecodeMimeHeader(newsgroups, charset, PR_FALSE, PR_TRUE);
|
||||||
PR_FREEIF(val);
|
cFields->SetNewsgroups(val ? val : newsgroups);
|
||||||
|
PR_FREEIF(val);
|
||||||
val = MIME_DecodeMimeHeader(priority, charset, PR_FALSE, PR_TRUE);
|
}
|
||||||
cFields->SetPriority(val ? val : priority);
|
|
||||||
PR_FREEIF(val);
|
if (followup_to) {
|
||||||
|
val = MIME_DecodeMimeHeader(followup_to, charset, PR_FALSE, PR_TRUE);
|
||||||
val = MIME_DecodeMimeHeader(newspost_url, charset, PR_FALSE, PR_TRUE);
|
cFields->SetFollowupTo(val ? val : followup_to);
|
||||||
cFields->SetNewspostUrl(val ? val : newspost_url);
|
PR_FREEIF(val);
|
||||||
PR_FREEIF(val);
|
}
|
||||||
|
|
||||||
|
if (organization) {
|
||||||
|
val = MIME_DecodeMimeHeader(organization, charset, PR_FALSE, PR_TRUE);
|
||||||
|
cFields->SetOrganization(NS_ConvertUTF8toUCS2(val ? val : organization).get());
|
||||||
|
PR_FREEIF(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (references) {
|
||||||
|
val = MIME_DecodeMimeHeader(references, charset, PR_FALSE, PR_TRUE);
|
||||||
|
cFields->SetReferences(val ? val : references);
|
||||||
|
PR_FREEIF(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (other_random_headers) {
|
||||||
|
val = MIME_DecodeMimeHeader(other_random_headers, charset, PR_FALSE, PR_TRUE);
|
||||||
|
cFields->SetOtherRandomHeaders(NS_ConvertUTF8toUCS2(val ? val : other_random_headers).get());
|
||||||
|
PR_FREEIF(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority) {
|
||||||
|
val = MIME_DecodeMimeHeader(priority, charset, PR_FALSE, PR_TRUE);
|
||||||
|
cFields->SetPriority(val ? val : priority);
|
||||||
|
PR_FREEIF(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newspost_url) {
|
||||||
|
val = MIME_DecodeMimeHeader(newspost_url, charset, PR_FALSE, PR_TRUE);
|
||||||
|
cFields->SetNewspostUrl(val ? val : newspost_url);
|
||||||
|
PR_FREEIF(val);
|
||||||
|
}
|
||||||
|
|
||||||
*_retval = cFields;
|
*_retval = cFields;
|
||||||
NS_IF_ADDREF(*_retval);
|
NS_IF_ADDREF(*_retval);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user