diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 8bc8d76605..558179833b 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -12912,8 +12912,8 @@ static int DsaKeyIntsToDer(DsaKey* key, byte* output, word32* inLen, seqSz = SetSequence(verSz + intTotalLen, seq); outLen = seqSz + verSz + intTotalLen; - *inLen = outLen; if (output == NULL) { + *inLen = outLen; FreeTmpDsas(tmps, key->heap, ints); return WC_NO_ERR_TRACE(LENGTH_ONLY_E); } @@ -12921,6 +12921,7 @@ static int DsaKeyIntsToDer(DsaKey* key, byte* output, word32* inLen, FreeTmpDsas(tmps, key->heap, ints); return BAD_FUNC_ARG; } + *inLen = outLen; /* write to output */ XMEMCPY(output, seq, seqSz);