clean up memory in error case with PKCS12 create

This commit is contained in:
Jacob Barthelmeh
2018-03-02 11:35:16 -07:00
parent 53c0bf6a20
commit ae23f777d6

View File

@ -18268,12 +18268,14 @@ WC_PKCS12* wolfSSL_PKCS12_create(char* pass, char* name,
curDer = (byte*)wolfSSL_X509_get_der(sk->data.x509, &curDerSz);
if (certDer == NULL || curDerSz < 0) {
XFREE(cur, NULL, DYNAMIC_TYPE_PKCS);
wc_FreeCertList(list, NULL);
return NULL;
}
cur->buffer = (byte*)XMALLOC(curDerSz, NULL, DYNAMIC_TYPE_PKCS);
if (cur->buffer == NULL) {
XFREE(cur, NULL, DYNAMIC_TYPE_PKCS);
wc_FreeCertList(list, NULL);
return NULL;
}