if (NS_SUCCEEDED(rv) && mimeFinder)
if (NS_SUCCEEDED(rv))
ValidateRealName(nsMsgAttachmentData *aAttach, MimeHeaders *aHdrs){   // Sanity.  if (!aAttach)    return;  // Do we need to validate?  if ( (aAttach->real_name) && (*(aAttach->real_name)) )    return;  // Internal MIME structures need not be named!  if ( (!aAttach->real_type) || (aAttach->real_type &&                                  !nsCRT::strncasecmp(aAttach->real_type, "multipart", 9)) )    return;  // Special case...if this is a enclosed RFC822 message, give it a nice  // name.  if (aAttach->real_type && !nsCRT::strcasecmp(aAttach->real_type, MESSAGE_RFC822))  {    NS_ASSERTION(aHdrs, "How comes the object's headers is null!");    if (aHdrs && aHdrs->munged_subject)      aAttach->real_name = PR_smprintf("%s.eml", aHdrs->munged_subject);    else      NS_MsgSACopy(&(aAttach->real_name), "ForwardedMessage.eml");    return;  }  //   // Now validate any other name we have for the attachment!  //  if (!aAttach->real_name || *aAttach->real_name == 0)  {    nsString  newAttachName(NS_LITERAL_STRING("attachment"));    nsresult  rv = NS_OK;    nsCAutoString contentType (aAttach->real_type);    PRInt32 pos = contentType.FindChar(';');    if (pos > 0)      contentType.Truncate(pos);    nsCOMPtr<nsIMIMEService> mimeFinder (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));    if (NS_SUCCEEDED(rv) && mimeFinder)     {      nsIMIMEInfo *mimeInfo = nsnull;      rv = mimeFinder->GetFromTypeAndExtension(contentType.get(), nsnull, &mimeInfo);      if (NS_SUCCEEDED(rv) && mimeInfo)       {        char *aFileExtension = nsnull;        if ( (NS_SUCCEEDED(mimeInfo->GetPrimaryExtension(&aFileExtension))) && aFileExtension)        {          newAttachName.Append(NS_LITERAL_STRING("."));          newAttachName.AppendWithConversion(aFileExtension);          PR_FREEIF(aFileExtension);        }      }            }    aAttach->real_name = ToNewCString(newAttachName);  }  }