2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-05 09:05:40 +00:00

fix unbalanced lock; test for non NULL before dereference;

This commit is contained in:
Mark Andrews
2014-06-11 21:42:36 +10:00
parent fc32eac99f
commit 0c57bf16a5

View File

@@ -231,6 +231,7 @@ isc_rng_create(isc_mem_t *mctx, isc_entropy_t *entropy, isc_rng_t **rngp) {
void
isc_rng_attach(isc_rng_t *source, isc_rng_t **targetp) {
REQUIRE(VALID_RNG(source));
REQUIRE(targetp != NULL && *targetp == NULL);
@@ -255,10 +256,13 @@ destroy(isc_rng_t **rngp) {
void
isc_rng_detach(isc_rng_t **rngp) {
isc_rng_t *rng = *rngp;
isc_rng_t *rng;
isc_boolean_t dest = ISC_FALSE;
REQUIRE(VALID_RNG(rng));
REQUIRE(rngp != NULL && VALID_RNG(*rngp));
rng = *rngp;
*rngp = NULL;
LOCK(&rng->lock);
@@ -266,13 +270,10 @@ isc_rng_detach(isc_rng_t **rngp) {
rng->references--;
if (rng->references == 0)
dest = ISC_TRUE;
UNLOCK(&rng->lock);
if (dest)
destroy(rngp);
else {
UNLOCK(&rng->lock);
*rngp = NULL;
}
}
static void