Fix double free

This commit is contained in:
Michał Trojnara 2019-07-11 20:20:47 +02:00
parent 6c8ec4427a
commit 4c44cfdd76

View File

@ -2729,7 +2729,7 @@ int main(int argc, char **argv) {
} }
if (certs == NULL && p7 != NULL) if (certs == NULL && p7 != NULL)
certs = p7->d.sign->cert; certs = sk_X509_dup(p7->d.sign->cert);
/* Check if indata is cab or pe */ /* Check if indata is cab or pe */
filesize = get_file_size(infile); filesize = get_file_size(infile);
@ -3179,7 +3179,7 @@ int main(int argc, char **argv) {
for(i = sk_X509_num(certs)-1; i>=0; i--) for(i = sk_X509_num(certs)-1; i>=0; i--)
PKCS7_add_certificate(sig, sk_X509_value(certs, i)); PKCS7_add_certificate(sig, sk_X509_value(certs, i));
if (p7 == NULL || certs != p7->d.sign->cert) { if (certs) {
sk_X509_free(certs); sk_X509_free(certs);
certs = NULL; certs = NULL;
} }
@ -3373,7 +3373,7 @@ err_cleanup:
pass = NULL; pass = NULL;
} }
ERR_print_errors_fp(stderr); ERR_print_errors_fp(stderr);
if (certs && (p7 == NULL || certs != p7->d.sign->cert)) if (certs)
sk_X509_free(certs); sk_X509_free(certs);
if (p7) if (p7)
PKCS7_free(p7); PKCS7_free(p7);