Aric Stewart : msi: Fix some NULL checking in MSI_RecordGetStringA.
Alexandre Julliard
julliard at winehq.org
Thu Dec 18 08:08:55 CST 2008
Module: wine
Branch: master
Commit: 17ffb562aa41fce32c3745d078c3a9792b1b5ef5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=17ffb562aa41fce32c3745d078c3a9792b1b5ef5
Author: Aric Stewart <aric at codeweavers.com>
Date: Wed Dec 17 10:14:50 2008 -0600
msi: Fix some NULL checking in MSI_RecordGetStringA.
Includes a few record tests with a NULL buffer.
---
dlls/msi/record.c | 7 ++++---
dlls/msi/tests/record.c | 10 ++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/msi/record.c b/dlls/msi/record.c
index 8b987f8..b02fcd1 100644
--- a/dlls/msi/record.c
+++ b/dlls/msi/record.c
@@ -358,15 +358,16 @@ UINT MSI_RecordGetStringA(MSIRECORD *rec, UINT iField,
case MSIFIELD_WSTR:
len = WideCharToMultiByte( CP_ACP, 0, rec->fields[iField].u.szwVal, -1,
NULL, 0 , NULL, NULL);
- WideCharToMultiByte( CP_ACP, 0, rec->fields[iField].u.szwVal, -1,
- szValue, *pcchValue, NULL, NULL);
+ if (szValue)
+ WideCharToMultiByte( CP_ACP, 0, rec->fields[iField].u.szwVal, -1,
+ szValue, *pcchValue, NULL, NULL);
if( szValue && *pcchValue && len>*pcchValue )
szValue[*pcchValue-1] = 0;
if( len )
len--;
break;
case MSIFIELD_NULL:
- if( *pcchValue > 0 )
+ if( szValue && *pcchValue > 0 )
szValue[0] = 0;
break;
default:
diff --git a/dlls/msi/tests/record.c b/dlls/msi/tests/record.c
index f211318..29a57a0 100644
--- a/dlls/msi/tests/record.c
+++ b/dlls/msi/tests/record.c
@@ -362,6 +362,11 @@ static void test_MsiRecordGetString(void)
ok(rec != 0, "Expected a valid handle\n");
sz = MAX_PATH;
+ r = MsiRecordGetString(rec, 1, NULL, &sz);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n",r);
+ ok(sz == 0, "Expected 0, got %d\n",sz);
+
+ sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
@@ -384,6 +389,11 @@ static void test_MsiRecordGetString(void)
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
+ r = MsiRecordGetString(rec, 1, NULL, &sz);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n",r);
+ ok(sz == 1, "Expected 1, got %d\n",sz);
+
+ sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiRecordGetString(rec, 1, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
More information about the wine-cvs
mailing list