fix FMM and UMR from purify, add some null sanity checks to fix various

crashers that I've seen.


git-svn-id: svn://10.0.0.236/trunk@56309 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sspitzer%netscape.com 1999-12-21 23:11:17 +00:00
parent 2e52c17f46
commit 9811a371d0
7 changed files with 37 additions and 27 deletions

View File

@ -21,6 +21,7 @@
*/
#include "nsAFMObject.h"
#include "nsFileSpec.h" // for nsAutoCString
#include "Helvetica.h"
#include "Helvetica-Bold.h"
#include "Helvetica-BoldOblique.h"
@ -285,13 +286,11 @@ PRBool bvalue;
AFMKey key;
double value;
PRInt32 ivalue;
char *AFMFileName; // file we will open
nsAutoCString AFMFileName(aFontName.name); // file we will open
AFMFileName = aFontName.name.ToNewCString();
// Open the file
mAFMFile = fopen(AFMFileName,"r");
mAFMFile = fopen((const char *)AFMFileName,"r");
if(nsnull != mAFMFile) {
// create the structure to put the information in
@ -430,7 +429,6 @@ char *AFMFileName; // file we will open
//memcpy(mPSFontInfo->mAFMCharMetrics,AFMHelveticaChars,HelveticaAFM.mNumCharacters*sizeof(AFMscm));
}
delete [] AFMFileName;
return(success);
}

View File

@ -57,6 +57,8 @@ char* paper_string[]={ "Letter", "Legal", "Executive", "A4" };
*/
nsPostScriptObj::nsPostScriptObj()
{
mPrintContext = nsnull;
mPrintSetup = nsnull;
}
/** ---------------------------------------------------
@ -90,10 +92,13 @@ nsPostScriptObj::~nsPostScriptObj()
delete mPrintContext->prSetup;
}
delete mPrintContext;
mPrintContext = nsnull;
}
if (nsnull != mPrintSetup)
if (nsnull != mPrintSetup) {
delete mPrintSetup;
mPrintSetup = nsnull;
}
}
/** ---------------------------------------------------

View File

@ -119,7 +119,11 @@ static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
nsRenderingContextPS :: nsRenderingContextPS()
{
NS_INIT_REFCNT();
mPSObj = nsnull; // local copy of printcontext, will be set on the init process
mContext = nsnull;
mFontMetrics = nsnull;
mStateCache = new nsVoidArray();
PushState();
@ -195,7 +199,9 @@ nsRenderingContextPS :: Init(nsIDeviceContext* aContext)
float app2dev;
mContext = aContext;
mPSObj = ((nsDeviceContextPS*)mContext)->GetPrintContext();
if (mContext) {
mPSObj = ((nsDeviceContextPS*)mContext)->GetPrintContext();
}
NS_IF_ADDREF(mContext);
// initialize the matrix
@ -524,7 +530,9 @@ NS_IMETHODIMP
nsRenderingContextPS :: SetFont(const nsFont& aFont)
{
NS_IF_RELEASE(mFontMetrics);
mContext->GetMetricsFor(aFont, mFontMetrics);
if (mContext) {
mContext->GetMetricsFor(aFont, mFontMetrics);
}
return NS_OK;
}

View File

@ -131,10 +131,9 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale)
}
#if defined(DEBUG_UNIX_COLLATION)
char* tmp = mLocale.ToNewCString();
if (NULL != tmp) {
printf("nsCollationUnix::Initialize mLocale = %s\n", tmp);
delete[] tmp;
nsAutoCString tmp(mLocale);
if (NULL != (const char *)tmp) {
printf("nsCollationUnix::Initialize mLocale = %s\n", (const char *)tmp);
}
#endif

View File

@ -27,6 +27,7 @@
#include "nsPosixLocale.h"
#include "nsLocaleCID.h"
#include "prprf.h"
#include "nsFileSpec.h"
NS_DEFINE_IID(kIPosixLocaleIID, NS_IPOSIXLOCALE_IID);
NS_DEFINE_IID(kPosixLocaleCID, NS_POSIXLOCALE_CID);
@ -47,18 +48,16 @@ nsPosixLocale::~nsPosixLocale(void)
NS_IMETHODIMP
nsPosixLocale::GetPlatformLocale(const nsString* locale,char* posixLocale, size_t length)
{
char* xp_locale;
char country_code[3];
char lang_code[3];
char extra[65];
char posix_locale[128];
nsAutoCString xp_locale(*locale);
xp_locale = locale->ToNewCString();
if (xp_locale!=nsnull) {
if (!ParseLocaleString(xp_locale,lang_code,country_code,extra,'-')) {
if ((const char *)xp_locale!=nsnull) {
if (!ParseLocaleString((const char *)xp_locale,lang_code,country_code,extra,'-')) {
// strncpy(posixLocale,"C",length);
PL_strncpyz(posixLocale,xp_locale,length); // use xp locale if parse failed
delete [] xp_locale;
PL_strncpyz(posixLocale,(const char *)xp_locale,length); // use xp locale if parse failed
return NS_OK;
}
@ -80,7 +79,6 @@ nsPosixLocale::GetPlatformLocale(const nsString* locale,char* posixLocale, size_
}
strncpy(posixLocale,posix_locale,length);
delete [] xp_locale;
return NS_OK;
}

View File

@ -336,14 +336,16 @@ nsresult nsMsgDBFolder::SendFlagNotifications(nsISupports *item, PRUint32 oldFla
// on the way out, it's the whole path.
nsresult nsMsgDBFolder::CreatePlatformLeafNameForDisk(const char *userLeafName, nsFileSpec &path, char **resultName)
{
#if 0
const int charLimit = MAX_FILE_LENGTH_WITHOUT_EXTENSION; // set on platform specific basis
#if XP_MAC
#endif
#if defined(XP_MAC)
nsCAutoString illegalChars = ":";
#elif defined(XP_OS2)
nsCAutoString illegalChars = "\"/\\[]:;=,|?<>*$. ";
#elif defined(XP_WIN32)
nsCAutoString illegalChars = "\"/\\[]:;=,|?<>*$";
#else // UNIX
#else // UNIX (what about beos?)
nsCAutoString illegalChars = "";
#endif

View File

@ -453,23 +453,23 @@ nsAppShellService::ShutdownComponent( const nsCID &aComponentCID ) {
if ( NS_SUCCEEDED( rv ) ) {
// Instance accessed, tell it to shutdown.
rv = component->Shutdown();
#ifdef NS_DEBUG
#ifdef NS_DEBUG
char *name = aComponentCID.ToString();
printf( "Shut down app shell component %s, rv=0x%08X\n",
name, (int)rv );
delete [] name;
#endif
nsCRT::free(name);
#endif
// Release the service.
nsServiceManager::ReleaseService( aComponentCID, component );
} else {
// Error getting component service (perhaps due to that component not being
// a service).
#ifdef NS_DEBUG
#ifdef NS_DEBUG
char *name = aComponentCID.ToString();
printf( "Unable to shut down app shell component %s, rv=0x%08X\n",
name, (int)rv );
delete [] name;
#endif
nsCRT::free(name);
#endif
}
return;