[PATCH 2/5] wbemprox: Avoid evaluating row conditions twice.
Hans Leidekker
hans at codeweavers.com
Wed Aug 28 07:14:26 CDT 2019
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
dlls/wbemprox/builtin.c | 9 ++++++---
dlls/wbemprox/query.c | 7 +++++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index 75cdfc3ba3..3d2a0679af 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -3026,7 +3026,7 @@ static enum fill_status fill_printer( struct table *table, const struct expr *co
WCHAR id[20];
EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &size, &count );
- if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
+ if (!count) return FILL_STATUS_UNFILTERED;
if (!(info = heap_alloc( size ))) return FILL_STATUS_FAILED;
if (!EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, (BYTE *)info, size, &size, &count ))
@@ -3093,7 +3093,11 @@ static enum fill_status fill_process( struct table *table, const struct expr *co
do
{
- if (!resize_table( table, row + 1, sizeof(*rec) )) goto done;
+ if (!resize_table( table, row + 1, sizeof(*rec) ))
+ {
+ status = FILL_STATUS_FAILED;
+ goto done;
+ }
rec = (struct record_process *)(table->data + offset);
rec->caption = heap_strdupW( entry.szExeFile );
@@ -3118,7 +3122,6 @@ static enum fill_status fill_process( struct table *table, const struct expr *co
TRACE("created %u rows\n", row);
table->num_rows = row;
- status = FILL_STATUS_UNFILTERED;
done:
CloseHandle( snap );
diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c
index 0165d2301b..e00f067e9e 100644
--- a/dlls/wbemprox/query.c
+++ b/dlls/wbemprox/query.c
@@ -404,13 +404,15 @@ HRESULT eval_cond( const struct table *table, UINT row, const struct expr *cond,
HRESULT execute_view( struct view *view )
{
UINT i, j = 0, len;
+ enum fill_status status = FILL_STATUS_UNFILTERED;
if (!view->table) return S_OK;
if (view->table->fill)
{
clear_table( view->table );
- view->table->fill( view->table, view->cond );
+ status = view->table->fill( view->table, view->cond );
}
+ if (status == FILL_STATUS_FAILED) return WBEM_E_FAILED;
if (!view->table->num_rows) return S_OK;
len = min( view->table->num_rows, 16 );
@@ -429,7 +431,8 @@ HRESULT execute_view( struct view *view )
if (!(tmp = heap_realloc( view->result, len * sizeof(UINT) ))) return E_OUTOFMEMORY;
view->result = tmp;
}
- if ((hr = eval_cond( view->table, i, view->cond, &val, &type )) != S_OK) return hr;
+ if (status == FILL_STATUS_FILTERED) val = 1;
+ else if ((hr = eval_cond( view->table, i, view->cond, &val, &type )) != S_OK) return hr;
if (val) view->result[j++] = i;
}
view->count = j;
--
2.20.1
More information about the wine-devel
mailing list