PORT_Assert(sigd);
NSS_CMSSignedData_SetDigestValue(NSSCMSSignedData *sigd,				SECOidTag digestalgtag,				SECItem *digestdata){    SECItem *digest = NULL;    PLArenaPool *poolp;    void *mark;    int n, cnt;    PORT_Assert(sigd);    if (!sigd) {        PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);        return SECFailure;    }    poolp = sigd->cmsg->poolp;    mark = PORT_ArenaMark(poolp);       if (digestdata) {        digest = (SECItem *) PORT_ArenaZAlloc(poolp,sizeof(SECItem));	/* copy digestdata item to arena (in case we have it and are not only making room) */	if (SECITEM_CopyItem(poolp, digest, digestdata) != SECSuccess)	    goto loser;    }    /* now allocate one (same size as digestAlgorithms) */    if (sigd->digests == NULL) {        cnt = NSS_CMSArray_Count((void **)sigd->digestAlgorithms);        sigd->digests = PORT_ArenaZAlloc(sigd->cmsg->poolp, (cnt + 1) * sizeof(SECItem *));        if (sigd->digests == NULL) {	        PORT_SetError(SEC_ERROR_NO_MEMORY);	        return SECFailure;        }    }    n = -1;    if (sigd->digestAlgorithms != NULL)	n = NSS_CMSAlgArray_GetIndexByAlgTag(sigd->digestAlgorithms, digestalgtag);    /* if not found, add a digest */    if (n < 0) {	if (NSS_CMSSignedData_AddDigest(poolp, sigd, digestalgtag, digest) != SECSuccess)	    goto loser;    } else {	/* replace NULL pointer with digest item (and leak previous value) */	sigd->digests[n] = digest;    }    PORT_ArenaUnmark(poolp, mark);    return SECSuccess;loser:    PORT_ArenaRelease(poolp, mark);    return SECFailure;}