Hans Leidekker : wbemprox: Avoid evaluating row conditions twice.
Alexandre Julliard
julliard at winehq.org
Wed Aug 28 18:23:20 CDT 2019
Module: wine
Branch: master
Commit: 08d928171c2e18156eb3239bb198dae6bb817bad
URL: https://source.winehq.org/git/wine.git/?a=commit;h=08d928171c2e18156eb3239bb198dae6bb817bad
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed Aug 28 14:14:26 2019 +0200
wbemprox: Avoid evaluating row conditions twice.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 75cdfc3..3d2a067 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 0165d23..e00f067 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;
More information about the wine-cvs
mailing list