Add isc_hashmap_find() DbC check for valuep

This adds DbC check, so we don't pass non-NULL memory for a valued to
the isc_hashmap_find() function.
This commit is contained in:
Ondřej Surý
2023-02-13 16:16:26 +01:00
parent 998252c6dc
commit 28fe8104ee
2 changed files with 4 additions and 4 deletions

View File

@@ -332,8 +332,9 @@ isc_hashmap_find(const isc_hashmap_t *hashmap, const uint32_t *hashvalp,
const void *key, uint32_t keysize, void **valuep) {
REQUIRE(ISC_HASHMAP_VALID(hashmap));
REQUIRE(key != NULL && keysize <= UINT16_MAX);
REQUIRE(valuep == NULL || *valuep == NULL);
hashmap_node_t *node;
hashmap_node_t *node = NULL;
uint8_t idx = hashmap->hindex;
uint32_t hashval = (hashvalp != NULL)
? *hashvalp

View File

@@ -381,7 +381,6 @@ ISC_RUN_TEST_IMPL(isc_hashmap_case) {
test_node_t lower = { .key = "isc_hashmap_case" };
test_node_t upper = { .key = "ISC_HASHMAP_CASE" };
test_node_t mixed = { .key = "IsC_hAsHmAp_CaSe" };
test_node_t *value;
isc_hashmap_create(mctx, 1, ISC_HASHMAP_CASE_SENSITIVE, &hashmap);
@@ -398,7 +397,7 @@ ISC_RUN_TEST_IMPL(isc_hashmap_case) {
assert_int_equal(result, ISC_R_SUCCESS);
result = isc_hashmap_find(hashmap, NULL, mixed.key, strlen(mixed.key),
(void *)&value);
&(void *){ NULL });
assert_int_equal(result, ISC_R_NOTFOUND);
isc_hashmap_destroy(&hashmap);
@@ -418,7 +417,7 @@ ISC_RUN_TEST_IMPL(isc_hashmap_case) {
assert_int_equal(result, ISC_R_EXISTS);
result = isc_hashmap_find(hashmap, NULL, mixed.key, strlen(mixed.key),
(void *)&value);
&(void *){ NULL });
assert_int_equal(result, ISC_R_SUCCESS);
isc_hashmap_destroy(&hashmap);