From da20e4d9ca4f1f410a6835b749eb8e2a0e5f8c5f Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Wed, 2 Nov 2005 19:58:01 +0000 Subject: [PATCH] NULL and empty strings are the same in conditions. --- dlls/msi/cond.y | 8 ++++++-- dlls/msi/tests/package.c | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dlls/msi/cond.y b/dlls/msi/cond.y index 0b1d74e4b87..7bf1dd9ea6e 100644 --- a/dlls/msi/cond.y +++ b/dlls/msi/cond.y @@ -361,6 +361,10 @@ static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub ) static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b ) { + /* null and empty string are equivalent */ + if (!a) a = szEmpty; + if (!b) b = szEmpty; + /* a or b may be NULL */ switch (operator) { @@ -377,7 +381,7 @@ static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b ) case COND_LE: return 1 != lstrcmpW( a, b ); case COND_SS: /* substring */ - return ( a && b && strstrW( a, b ) ) ? 1 : 0; + return strstrW( a, b ) ? 1 : 0; case COND_ILT: return -1 == lstrcmpiW( a, b ); case COND_IGT: @@ -391,7 +395,7 @@ static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b ) case COND_ILE: return 1 != lstrcmpiW( a, b ); case COND_ISS: - return ( a && b && strstriW( a, b ) ) ? 1 : 0; + return strstriW( a, b ) ? 1 : 0; case COND_LHS: case COND_RHS: case COND_ILHS: diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index 84b371a175b..d6e9bb42738 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -587,6 +587,12 @@ void test_condition(void) r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )"); ok( r == MSICONDITION_FALSE, "wrong return val\n"); + r = MsiEvaluateCondition(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd"); + ok( r == MSICONDITION_FALSE, "wrong return val\n"); + + r = MsiEvaluateCondition(hpkg, "Installed<>\"\""); + ok( r == MSICONDITION_FALSE, "wrong return val\n"); + MsiCloseHandle( hpkg ); }