summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lockdown.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index 1319e5d..21aa334 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -1213,10 +1213,13 @@ lockdownd_error_t lockdownd_gen_pair_cert(key_data_t public_key, key_data_t * od
/* copy buffer for output */
membp = BIO_new(BIO_s_mem());
if (membp && PEM_write_bio_X509(membp, dev_cert) > 0) {
- odevice_cert->size = BIO_get_mem_data(membp, &odevice_cert->data);
+ void *datap;
+ odevice_cert->size = BIO_get_mem_data(membp, &datap);
+ odevice_cert->data = malloc(odevice_cert->size);
+ memcpy(odevice_cert->data, datap, odevice_cert->size);
}
if (membp)
- free(membp);
+ BIO_free(membp);
ohost_cert->data = malloc(pem_host_cert.size);
memcpy(ohost_cert->data, pem_host_cert.data, pem_host_cert.size);