Commit 51f08d20 authored by Mark Andrews's avatar Mark Andrews
Browse files

Address potential thread issues:

Assign and then check node for NULL to address another thread
changing radix->head in the meantime.

Move 'node != NULL' check into while loop test to silence cppcheck
false positive.

Fix pointer != NULL style.
parent 6d5fde62
...@@ -232,15 +232,16 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target, ...@@ -232,15 +232,16 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target,
*target = NULL; *target = NULL;
if (radix->head == NULL) { node = radix->head;
if (node == NULL) {
return (ISC_R_NOTFOUND); return (ISC_R_NOTFOUND);
} }
node = radix->head;
addr = isc_prefix_touchar(prefix); addr = isc_prefix_touchar(prefix);
bitlen = prefix->bitlen; bitlen = prefix->bitlen;
while (node->bit < bitlen) { while (node != NULL && node->bit < bitlen) {
if (node->prefix) { if (node->prefix) {
stack[cnt++] = node; stack[cnt++] = node;
} }
...@@ -251,13 +252,9 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target, ...@@ -251,13 +252,9 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target,
} else { } else {
node = node->l; node = node->l;
} }
if (node == NULL) {
break;
}
} }
if (node && node->prefix) { if (node != NULL && node->prefix) {
stack[cnt++] = node; stack[cnt++] = node;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment