diff --git a/src/common/tests/acl_api_tests.c b/src/common/tests/acl_api_tests.c index 186121bfd46..79ad3b26ae1 100644 --- a/src/common/tests/acl_api_tests.c +++ b/src/common/tests/acl_api_tests.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2019-2021 Intel Corporation. + * (C) Copyright 2019-2023 Intel Corporation. * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -1035,7 +1035,8 @@ test_acl_add_ace_everyone_to_existing_list(void **state) static void expect_add_duplicate_ace_unchanged(enum daos_acl_principal_type type) { - int num_aces = NUM_DAOS_ACL_TYPES; + int num_aces = NUM_DAOS_ACL_TYPES; + ssize_t size; struct daos_ace *ace[num_aces]; struct daos_ace *new_ace; struct daos_acl *acl; @@ -1046,10 +1047,11 @@ expect_add_duplicate_ace_unchanged(enum daos_acl_principal_type type) orig_acl = daos_acl_dup(acl); /* Create an exact duplicate */ - D_ALLOC(new_ace, daos_ace_get_size(ace[type])); + size = daos_ace_get_size(ace[type]); + assert_true(size > 0); + D_ALLOC(new_ace, size); assert_non_null(new_ace); - memcpy(new_ace, ace[type], - daos_ace_get_size(ace[type])); + memcpy(new_ace, ace[type], size); assert_rc_equal(daos_acl_add_ace(&acl, new_ace), 0);