From 5756ca119aa9e9d88412e8c6f468f51c68799afe Mon Sep 17 00:00:00 2001 From: "ducarroz%netscape.com" Date: Fri, 14 Dec 2001 01:18:16 +0000 Subject: [PATCH] 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 git-svn-id: svn://10.0.0.236/trunk@110445 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/compose/src/nsMsgAttachment.cpp | 2 +- mozilla/mailnews/mime/src/mimemult.cpp | 3 ++- mozilla/uriloader/exthandler/mac/nsInternetConfigService.cpp | 4 ++-- mozilla/xpfe/appshell/src/nsInternetConfigService.cpp | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mozilla/mailnews/compose/src/nsMsgAttachment.cpp b/mozilla/mailnews/compose/src/nsMsgAttachment.cpp index fece96abf37..81b3e9103f4 100644 --- a/mozilla/mailnews/compose/src/nsMsgAttachment.cpp +++ b/mozilla/mailnews/compose/src/nsMsgAttachment.cpp @@ -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; diff --git a/mozilla/mailnews/mime/src/mimemult.cpp b/mozilla/mailnews/mime/src/mimemult.cpp index 4d61cbee188..3b7b2d13b55 100644 --- a/mozilla/mailnews/mime/src/mimemult.cpp +++ b/mozilla/mailnews/mime/src/mimemult.cpp @@ -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 diff --git a/mozilla/uriloader/exthandler/mac/nsInternetConfigService.cpp b/mozilla/uriloader/exthandler/mac/nsInternetConfigService.cpp index 68905281182..06daa9f63ed 100644 --- a/mozilla/uriloader/exthandler/mac/nsInternetConfigService.cpp +++ b/mozilla/uriloader/exthandler/mac/nsInternetConfigService.cpp @@ -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]); diff --git a/mozilla/xpfe/appshell/src/nsInternetConfigService.cpp b/mozilla/xpfe/appshell/src/nsInternetConfigService.cpp index 68905281182..06daa9f63ed 100644 --- a/mozilla/xpfe/appshell/src/nsInternetConfigService.cpp +++ b/mozilla/xpfe/appshell/src/nsInternetConfigService.cpp @@ -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]);