diff --git a/lib/asn1/der_copy.c b/lib/asn1/der_copy.c index 2084cef5f..f67fff69d 100644 --- a/lib/asn1/der_copy.c +++ b/lib/asn1/der_copy.c @@ -167,9 +167,13 @@ int ASN1CALL der_copy_octet_string (const heim_octet_string *from, heim_octet_string *to) { assert(from->length == 0 || (from->length > 0 && from->data != NULL)); - if (from->length == 0) + if (from->length == 0) { + if (from->data == NULL) { + *to = *from; + return 0; + } to->data = calloc(1, 1); - else + } else to->data = malloc(from->length); if (to->data == NULL) { to->length = 0;