summaryrefslogtreecommitdiff
path: root/source4/libcli/ldap/ldap_bind.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli/ldap/ldap_bind.c')
-rw-r--r--source4/libcli/ldap/ldap_bind.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/source4/libcli/ldap/ldap_bind.c b/source4/libcli/ldap/ldap_bind.c
index 2b209c3871..f1f7872455 100644
--- a/source4/libcli/ldap/ldap_bind.c
+++ b/source4/libcli/ldap/ldap_bind.c
@@ -370,15 +370,18 @@ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn, struct cli_credentials *cr
talloc_free(tmp_ctx);
if (NT_STATUS_IS_OK(status)) {
- struct socket_context *socket = gensec_socket_init(conn->gensec,
- conn->sock,
- conn->event.event_ctx,
- ldap_read_io_handler,
- conn);
- if (socket) {
- conn->sock = socket;
- talloc_steal(conn->sock, socket);
- packet_set_socket(conn->packet, socket);
+ struct socket_context *sasl_socket;
+ status = gensec_socket_init(conn->gensec,
+ conn->sock,
+ conn->event.event_ctx,
+ ldap_read_io_handler,
+ conn,
+ &sasl_socket);
+ if (NT_STATUS_IS_OK(status)) {
+ talloc_steal(conn->sock, sasl_socket);
+ talloc_unlink(conn, conn->sock);
+ conn->sock = sasl_socket;
+ packet_set_socket(conn->packet, conn->sock);
} else {
status = NT_STATUS_NO_MEMORY;
goto failed;