lib/asn1: prevent wrong size argument warnings

190263bb7a
("assert non-NULL ptrs before calling mem funcs") introduced
two wrong size argument warnings.  These locations are not
errors since the allocation is simply to ensure that the
data pointer is non-NULL; length is zero.

Change-Id: I7b3b58247799a48da3653008c7b6d7fbbbf83e25
This commit is contained in:
Jeffrey Altman
2022-01-24 00:31:27 -05:00
parent 190263bb7a
commit ee56cb33b2

View File

@@ -124,7 +124,7 @@ der_copy_bmp_string (const heim_bmp_string *from, heim_bmp_string *to)
{ {
assert(from->length == 0 || (from->length > 0 && from->data != NULL)); assert(from->length == 0 || (from->length > 0 && from->data != NULL));
if (from->length == 0) if (from->length == 0)
to->data = calloc(1, 1); to->data = calloc(1, sizeof(from->data[0]));
else else
to->data = malloc(from->length * sizeof(from->data[0])); to->data = malloc(from->length * sizeof(from->data[0]));
if (to->data == NULL) { if (to->data == NULL) {
@@ -143,7 +143,7 @@ der_copy_universal_string (const heim_universal_string *from,
{ {
assert(from->length == 0 || (from->length > 0 && from->data != NULL)); assert(from->length == 0 || (from->length > 0 && from->data != NULL));
if (from->length == 0) if (from->length == 0)
to->data = calloc(1, 1); to->data = calloc(1, sizeof(from->data[0]));
else else
to->data = malloc(from->length * sizeof(from->data[0])); to->data = malloc(from->length * sizeof(from->data[0]));
if (to->data == NULL) { if (to->data == NULL) {