From: Arran Cudbard-Bell Date: Thu, 27 Jul 2023 15:11:28 +0000 (-0400) Subject: ldap: Alloc all resources at the start of the function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f20113b16925ef7a7678c285285f4c89bc183bb;p=thirdparty%2Ffreeradius-server.git ldap: Alloc all resources at the start of the function --- diff --git a/src/lib/ldap/connection.c b/src/lib/ldap/connection.c index 6083c72531f..d74db6db7b9 100644 --- a/src/lib/ldap/connection.c +++ b/src/lib/ldap/connection.c @@ -341,6 +341,11 @@ static fr_connection_state_t _ldap_connection_init(void **h, fr_connection_t *co c = fr_ldap_connection_alloc(conn); c->conn = conn; + /* + * Initialise tree for outstanding queries handled by this connection + */ + MEM(c->queries = fr_rb_inline_talloc_alloc(c, fr_ldap_query_t, node, fr_ldap_query_cmp, NULL)); + fr_dlist_init(&c->refs, fr_ldap_query_t, entry); /* * Configure/allocate the libldap handle @@ -358,11 +363,6 @@ static fr_connection_state_t _ldap_connection_init(void **h, fr_connection_t *co state = fr_ldap_state_next(c); if (state == FR_LDAP_STATE_ERROR) goto error; - /* - * Initialise tree for outstanding queries handled by this connection - */ - MEM(c->queries = fr_rb_inline_talloc_alloc(c, fr_ldap_query_t, node, fr_ldap_query_cmp, NULL)); - fr_dlist_init(&c->refs, fr_ldap_query_t, entry); fr_connection_add_watch_pre(conn, FR_CONNECTION_STATE_CLOSED, _ldap_connection_close_watch, true, c); *h = c; /* Set the handle */