112266 r=ducarroz sr=bienvenu. free mimeGetStringById after use (fwd inline)

112287 r=ducarroz sr=bienvenu. fix leaking mime url by using nsCOMPtr (fwd inline)
This commit is contained in:
naving%netscape.com 2001-11-28 01:33:44 +00:00
parent 7cfd69c6a4
commit c8ec16032a
4 changed files with 25 additions and 24 deletions

View File

@ -92,7 +92,7 @@ class nsMsgAttachmentHandler;
// Attachment file/URL structures
struct nsMsgAttachmentData
{
nsIURI *url; // The URL to attach. This should be 0 to signify "end of list".
nsIURI* url; // The URL to attach. This should be 0 to signify "end of list".
char *desired_type; // The type to which this document should be
// converted. Legal values are NULL, TEXT_PLAIN
@ -126,7 +126,7 @@ struct nsMsgAttachmentData
//
typedef struct nsMsgAttachedFile
{
nsIURI *orig_url; // Where it came from on the network (or even elsewhere on the local disk.)
nsCOMPtr<nsIURI> orig_url; // Where it came from on the network (or even elsewhere on the local disk.)
nsFileSpec *file_spec; // The tmp file in which the (possibly converted) data now resides.

View File

@ -507,13 +507,13 @@ void nsEudoraCompose::ExtractType( nsString& str)
void nsEudoraCompose::CleanUpAttach( nsMsgAttachedFile *a, PRInt32 count)
{
for (PRInt32 i = 0; i < count; i++) {
NS_IF_RELEASE( a[i].orig_url);
if (a[i].type)
nsCRT::free( a[i].type);
if (a[i].description)
nsCRT::free( a[i].description);
if (a[i].encoding)
nsCRT::free( a[i].encoding);
a[i].orig_url=nsnull;
if (a[i].type)
nsCRT::free( a[i].type);
if (a[i].description)
nsCRT::free( a[i].description);
if (a[i].encoding)
nsCRT::free( a[i].encoding);
}
delete [] a;
@ -555,7 +555,7 @@ nsMsgAttachedFile * nsEudoraCompose::GetLocalAttachments( void)
CleanUpAttach( a, count);
return( nsnull);
}
rv = m_pIOService->NewURI( urlStr, nsnull, &(a[i].orig_url));
rv = m_pIOService->NewURI( urlStr, nsnull, getter_AddRefs(a[i].orig_url));
nsCRT::free( urlStr);
if (NS_FAILED( rv)) {
CleanUpAttach( a, count);

View File

@ -504,13 +504,13 @@ void nsOutlookCompose::ExtractType( nsString& str)
void nsOutlookCompose::CleanUpAttach( nsMsgAttachedFile *a, PRInt32 count)
{
for (PRInt32 i = 0; i < count; i++) {
NS_IF_RELEASE( a[i].orig_url);
if (a[i].type)
nsCRT::free( a[i].type);
if (a[i].description)
nsCRT::free( a[i].description);
if (a[i].encoding)
nsCRT::free( a[i].encoding);
a[i].orig_url=nsnull;
if (a[i].type)
nsCRT::free( a[i].type);
if (a[i].description)
nsCRT::free( a[i].description);
if (a[i].encoding)
nsCRT::free( a[i].encoding);
}
delete [] a;
@ -552,7 +552,7 @@ nsMsgAttachedFile * nsOutlookCompose::GetLocalAttachments( void)
CleanUpAttach( a, count);
return( nsnull);
}
rv = m_pIOService->NewURI( urlStr, nsnull, &(a[i].orig_url));
rv = m_pIOService->NewURI( urlStr, nsnull, getter_AddRefs(a[i].orig_url));
nsCRT::free( urlStr);
if (NS_FAILED( rv)) {
CleanUpAttach( a, count);

View File

@ -184,6 +184,7 @@ mime_dump_attachments ( nsMsgAttachmentData *attachData )
tmp->url->GetSpec(&spec);
printf("URL : %s\n", spec);
PR_FREEIF(spec);
}
printf("Desired Type : %s\n", tmp->desired_type);
@ -461,7 +462,7 @@ mime_free_attach_data ( nsMsgAttachmentData *attachData, int cleanupCount)
for ( i=0; i < cleanupCount; i++, tmp++ )
{
if ( tmp->url )
if (tmp->url)
delete tmp->url;
PR_FREEIF(tmp->real_name);
@ -486,8 +487,7 @@ mime_free_attachments ( nsMsgAttachedFile *attachments, int count )
for ( i = 0; i < count; i++, cur++ )
{
if ( cur->orig_url )
NS_RELEASE(cur->orig_url);
cur->orig_url=nsnull;
PR_FREEIF ( cur->type );
PR_FREEIF ( cur->encoding );
@ -698,8 +698,10 @@ MimeGetNamedString(PRInt32 id)
retString[0] = '\0';
char *tString = MimeGetStringByID(id);
if (tString)
{
PL_strncpy(retString, tString, sizeof(retString));
PR_Free(tString);
}
return retString;
}
@ -1847,8 +1849,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
nsFileURL fileURL(*tmpSpec);
const char * tempSpecStr = fileURL.GetURLString();
nsMimeNewURI(&(newAttachment->orig_url), tempSpecStr, nsnull);
NS_IF_ADDREF(newAttachment->orig_url);
nsMimeNewURI(getter_AddRefs(newAttachment->orig_url), tempSpecStr, nsnull);
}
PR_FREEIF(workURLSpec);