s3:smbldap: add a destructor to smbldap_state, just in case
[kai/samba.git] / source3 / lib / smbldap.c
index 41ba0e1b442f0f89356e4888dacd0e8a087ae507..1fbefbf2d59934022a6021e27c226133cb5efe23 100644 (file)
@@ -1853,6 +1853,12 @@ void smbldap_free_struct(struct smbldap_state **ldap_state)
        /* No need to free any further, as it is talloc()ed */
 }
 
+static int smbldap_state_destructor(struct smbldap_state *state)
+{
+       smbldap_free_struct(&state);
+       return 0;
+}
+
 
 /**********************************************************************
  Intitalise the 'general' ldap structures, on which ldap operations may be conducted
@@ -1876,6 +1882,7 @@ NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx, struct event_context *event_ctx,
 
        (*smbldap_state)->event_context = event_ctx;
 
+       talloc_set_destructor(*smbldap_state, smbldap_state_destructor);
        return NT_STATUS_OK;
 }