Module: wine Branch: stable Commit: c807811038de7cafd1ec646742f873924fc399b1 URL: https://gitlab.winehq.org/wine/wine/-/commit/c807811038de7cafd1ec646742f8739...
Author: Alex Henrie alexhenrie24@gmail.com Date: Wed Mar 15 22:30:50 2023 -0600
wldap32: Handle null LDAPMessage in ldap_count_entries.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54690 (cherry picked from commit 65323a6b967b8e214aec8d97a88c7f1dbf17cbca)
---
dlls/wldap32/misc.c | 1 + dlls/wldap32/tests/parse.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/wldap32/misc.c b/dlls/wldap32/misc.c index 5d49c412805..bf9afcf64b7 100644 --- a/dlls/wldap32/misc.c +++ b/dlls/wldap32/misc.c @@ -98,6 +98,7 @@ ULONG CDECL WLDAP32_ldap_count_entries( LDAP *ld, WLDAP32_LDAPMessage *res ) { TRACE( "(%p, %p)\n", ld, res );
+ if (!res) return 0; if (!ld) return ~0u; return ldap_count_entries( CTX(ld), MSG(res) ); } diff --git a/dlls/wldap32/tests/parse.c b/dlls/wldap32/tests/parse.c index 8394d5eeeff..161a0672cdc 100644 --- a/dlls/wldap32/tests/parse.c +++ b/dlls/wldap32/tests/parse.c @@ -252,7 +252,13 @@ static void test_ldap_paged_search(void) ok( res != NULL, "expected res != NULL\n" ); ok( count == 0, "got %lu\n", count );
- count = ldap_count_entries( ld, res); + count = ldap_count_entries( NULL, NULL ); + ok( count == 0, "got %lu\n", count ); + count = ldap_count_entries( ld, NULL ); + ok( count == 0, "got %lu\n", count ); + count = ldap_count_entries( NULL, res ); + todo_wine ok( count == 1, "got %lu\n", count ); + count = ldap_count_entries( ld, res ); ok( count == 1, "got %lu\n", count );
entry = ldap_first_entry( ld, res);