nsCRT::free(ic->type); ic->type = NULL; ic->type = nsCRT::strdup(contenttype);
IL_StreamFirstWrite(il_container *ic, const unsigned char *str, int32 len){  nsresult rv = NS_OK;	PR_ASSERT(ic);	PR_ASSERT(ic->image);        /* If URL redirection occurs, the url stored in the    image container is the redirect url not the image file url.    If the image is animated, the imglib will never match the    file name in the cache unless you update ic->url_address.    ic->fetch_url keeps the actual url for you.     */	    FREE_IF_NOT_NULL(ic->fetch_url);#ifdef NECKO    if (ic->url){	    ic->fetch_url = ic->url->GetAddress();    }#else    if((ic->url)&& ic->url->GetAddress()){	    ic->fetch_url = PL_strdup(ic->url->GetAddress());    }#endif    else{	if(ic->url_address) /* check needed because of mkicons.c */        	ic->fetch_url = PL_strdup(ic->url_address);	else		ic->fetch_url = NULL;    } 	/* Grab the URL's expiration date */	if (ic->url)	  ic->expires = ic->url->GetExpires();  nsIImgDecoder *imgdec ;	  char imgtypestr[200];  PR_snprintf(imgtypestr, sizeof(imgtypestr), "component://netscape/image/decoder&type=%s"            , ic->type );    static NS_DEFINE_IID(kIImgDecoderIID, NS_IIMGDECODER_IID);  rv = nsComponentManager::CreateInstance(imgtypestr, NULL,                                              kIImgDecoderIID,                                           (void **)&imgdec);  /* If no mimetype to decoder mapping, try to sniff out  the mime-type */  if (NS_FAILED(rv)){      char contenttype[50];      if(sniffout_mimetype((const char*) str, len, contenttype)){        /* try again with the guessed mimetype */        PR_snprintf(imgtypestr, sizeof(imgtypestr), "component://netscape/image/decoder&type=%s"            , contenttype );          rv = nsComponentManager::CreateInstance(imgtypestr, NULL,                                    kIImgDecoderIID, (void **)&imgdec);        }      if (NS_FAILED(rv))          /* we did our best. Gotta give up. */          return MK_IMAGE_LOSSAGE;             /*we found it*/      nsCRT::free(ic->type);      ic->type = NULL;      ic->type = nsCRT::strdup(contenttype);  }    imgdec->SetContainer(ic);  ic->imgdec = imgdec;    rv = imgdec->ImgDInit();  if(NS_FAILED(rv)){     NS_RELEASE(ic->imgdec);     ic->imgdec = nsnull;    ILTRACE(0,("il: image init failed"));    return MK_OUT_OF_MEMORY;  }			return 0; //ok}