Dmitry Timoshkov : adsldp: Always fully initialize returned column values.

Alexandre Julliard julliard at winehq.org
Mon Apr 6 15:53:22 CDT 2020


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

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Mon Apr  6 18:11:44 2020 +0800

adsldp: Always fully initialize returned column values.

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

---

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

diff --git a/dlls/adsldp/adsldp.c b/dlls/adsldp/adsldp.c
index a4467c0abe..2b5f621fba 100644
--- a/dlls/adsldp/adsldp.c
+++ b/dlls/adsldp/adsldp.c
@@ -1393,13 +1393,10 @@ static HRESULT add_column_values(LDAP_namespace *ldap, struct ldap_search_contex
     {
         WCHAR **values = ldap_get_valuesW(ldap->ld, ldap_ctx->entry, name);
         if (!values)
-        {
-            memset(col, 0, sizeof(*col));
             return E_ADS_COLUMN_NOT_SET;
-        }
         count = ldap_count_valuesW(values);
 
-        col->pADsValues = heap_alloc(count * sizeof(col->pADsValues[0]));
+        col->pADsValues = heap_alloc_zero(count * sizeof(col->pADsValues[0]));
         if (!col->pADsValues)
         {
             ldap_value_freeW(values);
@@ -1421,13 +1418,10 @@ static HRESULT add_column_values(LDAP_namespace *ldap, struct ldap_search_contex
     {
         WCHAR **values = ldap_get_valuesW(ldap->ld, ldap_ctx->entry, name);
         if (!values)
-        {
-            memset(col, 0, sizeof(*col));
             return E_ADS_COLUMN_NOT_SET;
-        }
         count = ldap_count_valuesW(values);
 
-        col->pADsValues = heap_alloc(count * sizeof(col->pADsValues[0]));
+        col->pADsValues = heap_alloc_zero(count * sizeof(col->pADsValues[0]));
         if (!col->pADsValues)
         {
             ldap_value_freeW(values);
@@ -1459,13 +1453,10 @@ static HRESULT add_column_values(LDAP_namespace *ldap, struct ldap_search_contex
     {
         WCHAR **values = ldap_get_valuesW(ldap->ld, ldap_ctx->entry, name);
         if (!values)
-        {
-            memset(col, 0, sizeof(*col));
             return E_ADS_COLUMN_NOT_SET;
-        }
         count = ldap_count_valuesW(values);
 
-        col->pADsValues = heap_alloc(count * sizeof(col->pADsValues[0]));
+        col->pADsValues = heap_alloc_zero(count * sizeof(col->pADsValues[0]));
         if (!col->pADsValues)
         {
             ldap_value_freeW(values);
@@ -1488,13 +1479,10 @@ static HRESULT add_column_values(LDAP_namespace *ldap, struct ldap_search_contex
     {
         struct berval **values = ldap_get_values_lenW(ldap->ld, ldap_ctx->entry, name);
         if (!values)
-        {
-            memset(col, 0, sizeof(*col));
             return E_ADS_COLUMN_NOT_SET;
-        }
         count = ldap_count_values_len(values);
 
-        col->pADsValues = heap_alloc(count * sizeof(col->pADsValues[0]));
+        col->pADsValues = heap_alloc_zero(count * sizeof(col->pADsValues[0]));
         if (!col->pADsValues)
         {
             ldap_value_free_len(values);
@@ -1533,6 +1521,8 @@ static HRESULT WINAPI search_GetColumn(IDirectorySearch *iface, ADS_SEARCH_HANDL
 
     if (!res || !name || !ldap_ctx->entry) return E_ADS_BAD_PARAMETER;
 
+    memset(col, 0, sizeof(*col));
+
     if (!wcsicmp(name, L"ADsPath"))
     {
         WCHAR *dn = ldap_get_dnW(ldap->ld, ldap_ctx->entry);




More information about the wine-cvs mailing list