From d63e32dd30132f79013ed1e6d12d201ed0b7c492 Mon Sep 17 00:00:00 2001 From: Marc Hoersken Date: Sun, 18 May 2014 14:58:21 +0200 Subject: [PATCH] wincng.c: Fixed memory leak in case of an error during ASN.1 decoding --- src/wincng.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/wincng.c b/src/wincng.c index 11b8633..f5390d2 100644 --- a/src/wincng.c +++ b/src/wincng.c @@ -669,23 +669,24 @@ _libssh2_wincng_asn_decode_bns(unsigned char *pbEncoded, break; } - if (ret) { + if (!ret) { + *prpbDecoded = rpbDecoded; + *prcbDecoded = rcbDecoded; + *pcbCount = length; + } else { for (length = 0; length < index; length++) { if (rpbDecoded[length]) { free(rpbDecoded[length]); rpbDecoded[length] = NULL; } } - } else { - *prpbDecoded = rpbDecoded; - *prcbDecoded = rcbDecoded; - *pcbCount = length; + free(rpbDecoded); + free(rcbDecoded); } } else { free(rpbDecoded); ret = -1; } - } else { ret = -1; }