[1/2] wbemprox: Use a separate index variable to build the safearray in get_properties.

Hans Leidekker hans at codeweavers.com
Tue May 13 06:41:35 CDT 2014


---
 dlls/wbemprox/query.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c
index c97b52b..b3a3eb9 100644
--- a/dlls/wbemprox/query.c
+++ b/dlls/wbemprox/query.c
@@ -963,12 +963,12 @@ HRESULT get_properties( const struct view *view, LONG flags, SAFEARRAY **props )
 {
     SAFEARRAY *sa;
     BSTR str;
-    LONG i;
-    UINT num_props = count_selected_properties( view );
+    UINT i, num_props = count_selected_properties( view );
+    LONG j;
 
     if (!(sa = SafeArrayCreateVector( VT_BSTR, 0, num_props ))) return E_OUTOFMEMORY;
 
-    for (i = 0; i < view->table->num_cols; i++)
+    for (i = 0, j = 0; i < view->table->num_cols; i++)
     {
         BOOL is_system;
 
@@ -980,12 +980,13 @@ HRESULT get_properties( const struct view *view, LONG flags, SAFEARRAY **props )
         else if ((flags & WBEM_FLAG_SYSTEM_ONLY) && !is_system) continue;
 
         str = SysAllocString( view->table->columns[i].name );
-        if (!str || SafeArrayPutElement( sa, &i, str ) != S_OK)
+        if (!str || SafeArrayPutElement( sa, &j, str ) != S_OK)
         {
             SysFreeString( str );
             SafeArrayDestroy( sa );
             return E_OUTOFMEMORY;
         }
+        j++;
     }
     *props = sa;
     return S_OK;
-- 
2.0.0.rc2






More information about the wine-patches mailing list