Module: wine Branch: master Commit: 5b8fdad9209570bd2f525b9fe359752ebc2501d1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5b8fdad9209570bd2f525b9fe3...
Author: Mike McCormack mike@codeweavers.com Date: Tue Nov 21 16:40:14 2006 +0900
msi: Fix use of integer fields in MsiFormatRecord.
---
dlls/msi/helpers.c | 27 +++++++++++++++++++++++++-- dlls/msi/tests/format.c | 4 ---- 2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/dlls/msi/helpers.c b/dlls/msi/helpers.c index ebd0301..3da5a05 100644 --- a/dlls/msi/helpers.c +++ b/dlls/msi/helpers.c @@ -67,9 +67,32 @@ LPWSTR build_icon_path(MSIPACKAGE *packa return FilePath; }
-LPWSTR msi_dup_record_field( MSIRECORD *row, INT index ) +LPWSTR msi_dup_record_field( MSIRECORD *rec, INT field ) { - return strdupW( MSI_RecordGetString(row,index) ); + DWORD sz = 0; + LPWSTR str; + UINT r; + + if (MSI_RecordIsNull( rec, field )) + return NULL; + + r = MSI_RecordGetStringW( rec, field, NULL, &sz ); + if (r != ERROR_SUCCESS) + return NULL; + + sz ++; + str = msi_alloc( sz * sizeof (WCHAR) ); + if (!str) + return str; + str[0] = 0; + r = MSI_RecordGetStringW( rec, field, str, &sz ); + if (r != ERROR_SUCCESS) + { + ERR("failed to get string!\n"); + msi_free( str ); + return NULL; + } + return str; }
MSICOMPONENT* get_loaded_component( MSIPACKAGE* package, LPCWSTR Component ) diff --git a/dlls/msi/tests/format.c b/dlls/msi/tests/format.c index 308bd70..37a1c08 100644 --- a/dlls/msi/tests/format.c +++ b/dlls/msi/tests/format.c @@ -927,10 +927,8 @@ static void test_formatrecord(void) sz = sizeof buffer; r = MsiFormatRecord(0, hrec, buffer, &sz); ok( r == ERROR_SUCCESS, "format failed\n"); - todo_wine{ ok( sz == 6, "size wrong\n"); ok( 0 == strcmp(buffer,"123456"), "wrong output (%s)\n",buffer); - }
r = MsiRecordSetString(hrec, 0, "[~]"); sz = sizeof buffer; @@ -1634,10 +1632,8 @@ static void test_formatrecord(void) MsiRecordSetString(hrec, 0, "[1] [2]"); r = MsiFormatRecord(0, hrec, buffer, &sz); ok( r == ERROR_SUCCESS, "format failed\n"); - todo_wine { ok( sz == 8, "size wrong(%i)\n",sz); ok( 0 == strcmp(buffer,"100 -100"), "wrong output (%s)\n",buffer); - }
MsiCloseHandle( hrec ); }