I'm not really sure if the last patch is the right way to fix the issue since I couldn't find where tls_w.c originates from.
-- v2: ldap: Free the output buffer after every InitializeSecurityContextA() call (Valgrind). wldap32: Fix a message leak in ldap_parse_resultW() (Valgrind).