break;
}
- /*
- * Bind auth ctx is freed by trunk request free.
- */
- fr_trunk_request_signal_complete(bind_auth_ctx->treq);
+ if (bind_auth_ctx->treq) {
+ /*
+ * Bind auth ctx is freed by trunk request free.
+ */
+ fr_trunk_request_signal_complete(bind_auth_ctx->treq);
+ } else {
+ /*
+ * If there is no trunk request, the request failed, and we need to free the ctx
+ */
+ talloc_free(bind_auth_ctx);
+ }
RETURN_MODULE_RCODE(rcode);
}
break;
}
- if (bind_auth_ctx->treq->tconn) ldap_conn = talloc_get_type_abort(bind_auth_ctx->treq->tconn->conn->h,
- fr_ldap_connection_t);
-
- /*
- * Will free bind_auth_ctx
- */
- fr_trunk_request_signal_complete(bind_auth_ctx->treq);
+ if (bind_auth_ctx->treq) {
+ if (bind_auth_ctx->treq->tconn) ldap_conn = talloc_get_type_abort(bind_auth_ctx->treq->tconn->conn->h,
+ fr_ldap_connection_t);
+ /*
+ * Will free bind_auth_ctx
+ */
+ fr_trunk_request_signal_complete(bind_auth_ctx->treq);
+ } else {
+ /*
+ * If there is no trunk request, the request failed, and we need to free the ctx
+ */
+ talloc_free(bind_auth_ctx);
+ }
switch (ret) {
case LDAP_PROC_SUCCESS: