Commit da20e4d9 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

NULL and empty strings are the same in conditions.

parent e6076846
...@@ -361,6 +361,10 @@ static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub ) ...@@ -361,6 +361,10 @@ static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub )
static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b ) 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 */ /* a or b may be NULL */
switch (operator) switch (operator)
{ {
...@@ -377,7 +381,7 @@ static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b ) ...@@ -377,7 +381,7 @@ static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b )
case COND_LE: case COND_LE:
return 1 != lstrcmpW( a, b ); return 1 != lstrcmpW( a, b );
case COND_SS: /* substring */ case COND_SS: /* substring */
return ( a && b && strstrW( a, b ) ) ? 1 : 0; return strstrW( a, b ) ? 1 : 0;
case COND_ILT: case COND_ILT:
return -1 == lstrcmpiW( a, b ); return -1 == lstrcmpiW( a, b );
case COND_IGT: case COND_IGT:
...@@ -391,7 +395,7 @@ static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b ) ...@@ -391,7 +395,7 @@ static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b )
case COND_ILE: case COND_ILE:
return 1 != lstrcmpiW( a, b ); return 1 != lstrcmpiW( a, b );
case COND_ISS: case COND_ISS:
return ( a && b && strstriW( a, b ) ) ? 1 : 0; return strstriW( a, b ) ? 1 : 0;
case COND_LHS: case COND_LHS:
case COND_RHS: case COND_RHS:
case COND_ILHS: case COND_ILHS:
......
...@@ -587,6 +587,12 @@ void test_condition(void) ...@@ -587,6 +587,12 @@ void test_condition(void)
r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )"); r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
ok( r == MSICONDITION_FALSE, "wrong return val\n"); 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 ); MsiCloseHandle( hpkg );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment