]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
only initialize the mutex if we succeed on insert
authorAlan T. DeKok <aland@freeradius.org>
Sat, 3 Apr 2021 13:21:15 +0000 (09:21 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 3 Apr 2021 13:21:15 +0000 (09:21 -0400)
on the off chance that pthread_mutex_init() allocates memory

src/main/listen.c

index 68aca8bd96579ec530ebb68e6d6534cb305db020..3919354aeb175114a3a75bbcd11c71a6750417e4 100644 (file)
@@ -3763,7 +3763,6 @@ retry:
                        talloc_free(coa_key);
                        return;
                }
-               (void) pthread_mutex_init(&coa_key->mutex, NULL);
 
                if (!rbtree_insert(coa_tree, coa_key)) {
                        talloc_free(coa_key);
@@ -3779,6 +3778,8 @@ retry:
                        tries++;
                        return;
                }
+
+               (void) pthread_mutex_init(&coa_key->mutex, NULL);
        }
 
        this->key = coa_key->key; /* no reason to duplicate the key */