]> 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>
Thu, 22 Jul 2021 13:55:23 +0000 (09:55 -0400)
on the off chance that pthread_mutex_init() allocates memory

src/main/listen.c

index f6b61103d3aa7b96282b2c9b817925e6ee9efde1..38993dc44a9cd90966ee626f521836731e82b459 100644 (file)
@@ -3800,7 +3800,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);
@@ -3816,6 +3815,8 @@ retry:
                        tries++;
                        return;
                }
+
+               (void) pthread_mutex_init(&coa_key->mutex, NULL);
        }
 
        this->key = coa_key->key; /* no reason to duplicate the key */