Piotr Caban : msi: Add error handling when retriving component/ feature state/action in condition.
Alexandre Julliard
julliard at winehq.org
Wed Oct 25 13:58:43 CDT 2017
Module: wine
Branch: master
Commit: 9ce8592b0680e31c2bb4bd723421ff20c4f3719c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9ce8592b0680e31c2bb4bd723421ff20c4f3719c
Author: Piotr Caban <piotr at codeweavers.com>
Date: Tue Oct 24 15:03:00 2017 +0200
msi: Add error handling when retriving component/feature state/action in condition.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msi/cond.y | 46 ++++++++++++++++++++++++++++++++--------------
dlls/msi/tests/package.c | 8 +++++++-
2 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/dlls/msi/cond.y b/dlls/msi/cond.y
index 712050c..6ee6ab9 100644
--- a/dlls/msi/cond.y
+++ b/dlls/msi/cond.y
@@ -321,9 +321,16 @@ value:
COND_input* cond = (COND_input*) info;
INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
- MSI_GetComponentStateW(cond->package, $2, &install, &action );
- $$.type = VALUE_INTEGER;
- $$.u.integer = action;
+ if(MSI_GetComponentStateW(cond->package, $2, &install, &action ) != ERROR_SUCCESS)
+ {
+ $$.type = VALUE_LITERAL;
+ $$.u.string = NULL;
+ }
+ else
+ {
+ $$.type = VALUE_INTEGER;
+ $$.u.integer = action;
+ }
cond_free( $2 );
}
| COND_QUESTION identifier
@@ -331,9 +338,16 @@ value:
COND_input* cond = (COND_input*) info;
INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
- MSI_GetComponentStateW(cond->package, $2, &install, &action );\
- $$.type = VALUE_INTEGER;
- $$.u.integer = install;
+ if(MSI_GetComponentStateW(cond->package, $2, &install, &action ) != ERROR_SUCCESS)
+ {
+ $$.type = VALUE_LITERAL;
+ $$.u.string = NULL;
+ }
+ else
+ {
+ $$.type = VALUE_INTEGER;
+ $$.u.integer = install;
+ }
cond_free( $2 );
}
| COND_AMPER identifier
@@ -343,17 +357,14 @@ value:
if (MSI_GetFeatureStateW(cond->package, $2, &install, &action ) != ERROR_SUCCESS)
{
- FIXME("condition may be evaluated incorrectly\n");
- /* we should return empty string in this case */
- $$.type = VALUE_INTEGER;
- $$.u.integer = MSICONDITION_FALSE;
+ $$.type = VALUE_LITERAL;
+ $$.u.string = NULL;
}
else
{
$$.type = VALUE_INTEGER;
$$.u.integer = action;
}
-
cond_free( $2 );
}
| COND_EXCLAM identifier
@@ -361,9 +372,16 @@ value:
COND_input* cond = (COND_input*) info;
INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
- MSI_GetFeatureStateW(cond->package, $2, &install, &action );
- $$.type = VALUE_INTEGER;
- $$.u.integer = install;
+ if(MSI_GetFeatureStateW(cond->package, $2, &install, &action ) != ERROR_SUCCESS)
+ {
+ $$.type = VALUE_LITERAL;
+ $$.u.string = NULL;
+ }
+ else
+ {
+ $$.type = VALUE_INTEGER;
+ $$.u.integer = install;
+ }
cond_free( $2 );
}
;
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index 3120252..002e692 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -2070,7 +2070,13 @@ static void test_condition(void)
r = MsiEvaluateConditionA(hpkg, "&nofeature");
ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
r = MsiEvaluateConditionA(hpkg, "&nofeature=\"\"");
- todo_wine ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
+ ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
+ r = MsiEvaluateConditionA(hpkg, "!nofeature=\"\"");
+ ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
+ MsiEvaluateConditionA(hpkg, "$nocomponent=\"\"");
+ ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
+ MsiEvaluateConditionA(hpkg, "?nocomponent=\"\"");
+ ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
MsiSetPropertyA(hpkg, "A", "2");
MsiSetPropertyA(hpkg, "X", "50");
More information about the wine-cvs
mailing list