@@ -36359,18 +36359,20 @@ word32 EncodeOcspRequestExtensions(OcspRequest* req, byte* output, word32 size)
3635936359 /* Check request has nonce to write in extension. */
3636036360 if (req != NULL && req->nonceSz != 0) {
3636136361 DECL_ASNSETDATA(dataASN, ocspNonceExtASN_Length);
36362- int sz;
36362+ int sz = 0 ;
3636336363
3636436364 CALLOC_ASNSETDATA(dataASN, ocspNonceExtASN_Length, ret, req->heap);
3636536365
36366- /* Set nonce extension OID and nonce. */
36367- SetASN_Buffer(&dataASN[OCSPNONCEEXTASN_IDX_EXT_OID], NonceObjId,
36368- sizeof(NonceObjId));
36369- SetASN_Buffer(&dataASN[OCSPNONCEEXTASN_IDX_EXT_NONCE], req->nonce,
36370- (word32)req->nonceSz);
36371- /* Calculate size of nonce extension. */
36372- ret = SizeASN_Items(ocspNonceExtASN, dataASN, ocspNonceExtASN_Length,
36373- &sz);
36366+ if ((ret == 0) && (output != NULL)) {
36367+ /* Set nonce extension OID and nonce. */
36368+ SetASN_Buffer(&dataASN[OCSPNONCEEXTASN_IDX_EXT_OID], NonceObjId,
36369+ sizeof(NonceObjId));
36370+ SetASN_Buffer(&dataASN[OCSPNONCEEXTASN_IDX_EXT_NONCE], req->nonce,
36371+ (word32)req->nonceSz);
36372+ /* Calculate size of nonce extension. */
36373+ ret = SizeASN_Items(ocspNonceExtASN, dataASN,
36374+ ocspNonceExtASN_Length, &sz);
36375+ }
3637436376 /* Check buffer big enough for encoding if supplied. */
3637536377 if ((ret == 0) && (output != NULL) && (sz > (int)size)) {
3637636378 ret = BUFFER_E;
0 commit comments