wincng.c: Fixed memory leak in case of an error during ASN.1 decoding

This commit is contained in:
Marc Hoersken 2014-05-18 14:58:21 +02:00
parent c32e82e97b
commit d63e32dd30

View File

@ -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;
}