From 4e10173eed583ffc035b4217594456e85d69d869 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 22 Jan 2018 16:17:08 -0800 Subject: [PATCH] Fix for possible leak in error case for `wc_RsaKeyToDer`. --- wolfcrypt/src/asn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index a4dcf3ad3..ad803db67 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -7287,8 +7287,10 @@ int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen) seqSz = SetSequence(verSz + intTotalLen, seq); outLen = seqSz + verSz + intTotalLen; - if (outLen > (int)inLen) + if (outLen > (int)inLen) { + FreeTmpRsas(tmps, key->heap); return BAD_FUNC_ARG; + } /* write to output */ XMEMCPY(output, seq, seqSz);