if(NS_FAILED(rv)) {
if(NS_FAILED(rv)){ NS_RELEASE(ic->imgdec); ic->imgdec = nsnull;
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;    }     /* Figure out the image type, possibly overriding the given MIME type */    ic->type = il_type(ic->type, (const char*) str, len);	/* Grab the URL's expiration date */	if (ic->url)	  ic->expires = ic->url->GetExpires();  nsIImgDecoder *imgdec;	  char imgtype[150];  char imgtypestr[200];  switch (ic->type) {    case IL_GIF : PL_strcpy(imgtype, "gif"); break;    case IL_XBM : PL_strcpy(imgtype, "xbm"); break;    case IL_JPEG : PL_strcpy(imgtype, "jpeg"); break;    case IL_PNG : PL_strcpy(imgtype, "png"); break;	case IL_ART : PL_strcpy(imgtype, "art"); break;    default : PL_strcpy(imgtype, "");    }  sprintf(imgtypestr, "component://netscape/image/decoder&type=image/%s"            , imgtype );  static NS_DEFINE_IID(kIImgDecoderIID, NS_IIMGDECODER_IID);  rv = nsComponentManager::CreateInstance(imgtypestr, NULL,                                                    kIImgDecoderIID, // XXX was previously kImgDecoderIID                                                (void **)&imgdec);  if (NS_FAILED(rv))    return MK_IMAGE_LOSSAGE;    imgdec->SetContainer(ic);  ic->imgdec = imgdec;    rv = imgdec->ImgDInit();  if(NS_FAILED(rv))  {    ILTRACE(0,("il: image init failed"));    return MK_OUT_OF_MEMORY;  }			return 0; //ok}