rv = SEC_ASN1DecodeItem(arena, &basestringitem, SEC_IA5StringTemplate,
rv = SEC_QuickDERDecodeItem(arena, &basestringitem, SEC_IA5StringTemplate,
CERT_FindCertURLExtension(CERTCertificate *cert, int tag, int catag){    SECStatus rv;    SECItem urlitem;    SECItem baseitem;    SECItem urlstringitem = {siBuffer,0};    SECItem basestringitem = {siBuffer,0};    PRArenaPool *arena = NULL;    PRBool hasbase;    char *urlstring;    char *str;    int len;    int i;        urlstring = NULL;    arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);    if ( ! arena ) {	goto loser;    }        hasbase = PR_FALSE;    urlitem.data = NULL;    baseitem.data = NULL;        rv = cert_FindExtension(cert->extensions, tag, &urlitem);    if ( rv == SECSuccess ) {	rv = cert_FindExtension(cert->extensions, SEC_OID_NS_CERT_EXT_BASE_URL,				   &baseitem);	if ( rv == SECSuccess ) {	    hasbase = PR_TRUE;	}	    } else if ( catag ) {	/* if the cert doesn't have the extensions, see if the issuer does */	rv = CERT_FindIssuerCertExtension(cert, catag, &urlitem);	if ( rv != SECSuccess ) {	    goto loser;	}	    	rv = CERT_FindIssuerCertExtension(cert, SEC_OID_NS_CERT_EXT_BASE_URL,					 &baseitem);	if ( rv == SECSuccess ) {	    hasbase = PR_TRUE;	}    } else {	goto loser;    }    rv = SEC_ASN1DecodeItem(arena, &urlstringitem, SEC_IA5StringTemplate, 			    &urlitem);    if ( rv != SECSuccess ) {	goto loser;    }    if ( hasbase ) {	rv = SEC_ASN1DecodeItem(arena, &basestringitem, SEC_IA5StringTemplate,				&baseitem);	if ( rv != SECSuccess ) {	    goto loser;	}    }        len = urlstringitem.len + ( hasbase ? basestringitem.len : 0 ) + 1;        str = urlstring = (char *)PORT_Alloc(len);    if ( urlstring == NULL ) {	goto loser;    }        /* copy the URL base first */    if ( hasbase ) {	/* if the urlstring has a : in it, then we assume it is an absolute	 * URL, and will not get the base string pre-pended	 */	for ( i = 0; i < urlstringitem.len; i++ ) {	    if ( urlstringitem.data[i] == ':' ) {		goto nobase;	    }	}		PORT_Memcpy(str, basestringitem.data, basestringitem.len);	str += basestringitem.len;	    }nobase:    /* copy the rest (or all) of the URL */    PORT_Memcpy(str, urlstringitem.data, urlstringitem.len);    str += urlstringitem.len;        *str = '\0';    goto done;    loser:    if ( urlstring ) {	PORT_Free(urlstring);    }        urlstring = NULL;done:    if ( arena ) {	PORT_FreeArena(arena, PR_FALSE);    }    if ( baseitem.data ) {	PORT_Free(baseitem.data);    }    if ( urlitem.data ) {	PORT_Free(urlitem.data);    }    return(urlstring);}