From: Mark Andrews Date: Wed, 24 Jun 2020 03:42:30 +0000 (+1000) Subject: Address potential thread issues: X-Git-Tag: v9.17.3~38^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51f08d20954f7eb5601dc7aca0cfa80d438db107;p=thirdparty%2Fbind9.git 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. --- diff --git a/lib/isc/radix.c b/lib/isc/radix.c index 72416a61a59..fccad5baae1 100644 --- a/lib/isc/radix.c +++ b/lib/isc/radix.c @@ -232,15 +232,16 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target, *target = NULL; - if (radix->head == NULL) { + node = radix->head; + + if (node == NULL) { return (ISC_R_NOTFOUND); } - node = radix->head; addr = isc_prefix_touchar(prefix); bitlen = prefix->bitlen; - while (node->bit < bitlen) { + while (node != NULL && node->bit < bitlen) { if (node->prefix) { stack[cnt++] = node; } @@ -251,13 +252,9 @@ isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target, } else { node = node->l; } - - if (node == NULL) { - break; - } } - if (node && node->prefix) { + if (node != NULL && node->prefix) { stack[cnt++] = node; }