Dmitry Timoshkov : adsldp: Improve IDirectorySearch::GetNextRow() end of entries detection logic.

Alexandre Julliard julliard at winehq.org
Thu Mar 26 16:27:25 CDT 2020


Module: wine
Branch: master
Commit: d2ab8296d48e4c0148ab48bf61aa719d39af7bb4
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d2ab8296d48e4c0148ab48bf61aa719d39af7bb4

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Thu Mar 26 15:09:20 2020 +0800

adsldp: Improve IDirectorySearch::GetNextRow() end of entries detection logic.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/adsldp/adsldp.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/dlls/adsldp/adsldp.c b/dlls/adsldp/adsldp.c
index e3b0bce9a2..350523222a 100644
--- a/dlls/adsldp/adsldp.c
+++ b/dlls/adsldp/adsldp.c
@@ -1211,11 +1211,9 @@ static HRESULT WINAPI search_GetFirstRow(IDirectorySearch *iface, ADS_SEARCH_HAN
 
     if (!res) return E_ADS_BAD_PARAMETER;
 
-    ldap_ctx->count = ldap_count_entries(ldap->ld, ldap_ctx->res);
-    ldap_ctx->pos = 0;
-    ldap_ctx->entry = ldap_first_entry(ldap->ld, ldap_ctx->res);
+    ldap_ctx->entry = NULL;
 
-    return ldap_ctx->entry ? S_OK : S_ADS_NOMORE_ROWS;
+    return IDirectorySearch_GetNextRow(iface, res);
 }
 
 static HRESULT WINAPI search_GetNextRow(IDirectorySearch *iface, ADS_SEARCH_HANDLE res)
@@ -1233,6 +1231,10 @@ static HRESULT WINAPI search_GetNextRow(IDirectorySearch *iface, ADS_SEARCH_HAND
     {
         ldap_ctx->count = ldap_count_entries(ldap->ld, ldap_ctx->res);
         ldap_ctx->pos = 0;
+
+        if (ldap_ctx->pos >= ldap_ctx->count)
+            return S_ADS_NOMORE_ROWS;
+
         ldap_ctx->entry = ldap_first_entry(ldap->ld, ldap_ctx->res);
     }
     else
@@ -1241,10 +1243,14 @@ static HRESULT WINAPI search_GetNextRow(IDirectorySearch *iface, ADS_SEARCH_HAND
             return S_ADS_NOMORE_ROWS;
 
         ldap_ctx->entry = ldap_next_entry(ldap->ld, ldap_ctx->res);
-        ldap_ctx->pos++;
     }
 
-    return ldap_ctx->entry ? S_OK : S_ADS_NOMORE_ROWS;
+    if (!ldap_ctx->entry)
+        return S_ADS_NOMORE_ROWS;
+
+    ldap_ctx->pos++;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI search_GetPreviousRow(IDirectorySearch *iface, ADS_SEARCH_HANDLE res)




More information about the wine-cvs mailing list