[PATCH 3/7] adsldp: Always fully initialize returned column values.

Dmitry Timoshkov dmitry at baikal.ru
Mon Apr 6 05:11:44 CDT 2020


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 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);
-- 
2.25.2




More information about the wine-devel mailing list