Fix for bug 111305. Check for null ptr before using it. Don't truncate and initialize a nsString with a length of -1, that cause the whole app to freeze. R=damn, SR=mscott, A=asa

This commit is contained in:
ducarroz%netscape.com 2001-12-14 01:18:16 +00:00
parent 9c4bfebf91
commit 6f175430bb
4 changed files with 7 additions and 6 deletions

View File

@ -124,7 +124,7 @@ NS_IMETHODIMP nsMsgAttachment::SetContentType(const char * aContentType)
keep only the content type alone. Therefore we need to cleanup it.
*/
PRInt32 offset = mContentType.FindChar(';');
if (offset)
if (offset >= 0)
mContentType.Truncate(offset);
return NS_OK;

View File

@ -456,7 +456,8 @@ MimeMultipart_create_child(MimeObject *obj)
{
struct mime_stream_data *msd = (struct mime_stream_data *)body->options->stream_closure;
if (!body->options->write_html_p && body->content_type && !nsCRT::strcasecmp(body->content_type, APPLICATION_APPLEFILE))
msd->channel->SetContentType(APPLICATION_APPLEFILE);
if (msd && msd->channel)
msd->channel->SetContentType(APPLICATION_APPLEFILE);
}
#endif

View File

@ -295,8 +295,8 @@ nsresult nsInternetConfigService::FillMIMEInfoForICEntry(ICMapEntry& entry, nsIM
// convert entry.extension which is a Str255
// don't forget to remove the '.' in front of the file extension....
nsCAutoString temp((char *)&entry.extension[2], (int)entry.extension[0]-1);
info->AppendExtension(temp.get());
nsCAutoString temp((char *)&entry.extension[2], entry.extension[0] > 0 ? (int)entry.extension[0]-1 : 0);
info->AppendExtension(temp.get());
info->SetMacType(entry.fileType);
info->SetMacCreator(entry.fileCreator);
temp.Assign((char *) &entry.entryName[1], entry.entryName[0]);

View File

@ -295,8 +295,8 @@ nsresult nsInternetConfigService::FillMIMEInfoForICEntry(ICMapEntry& entry, nsIM
// convert entry.extension which is a Str255
// don't forget to remove the '.' in front of the file extension....
nsCAutoString temp((char *)&entry.extension[2], (int)entry.extension[0]-1);
info->AppendExtension(temp.get());
nsCAutoString temp((char *)&entry.extension[2], entry.extension[0] > 0 ? (int)entry.extension[0]-1 : 0);
info->AppendExtension(temp.get());
info->SetMacType(entry.fileType);
info->SetMacCreator(entry.fileCreator);
temp.Assign((char *) &entry.entryName[1], entry.entryName[0]);