Hans Leidekker : msi: Return correct length for the empty string from deformat_string.
Alexandre Julliard
julliard at winehq.org
Wed Nov 7 14:02:28 CST 2012
Module: wine
Branch: master
Commit: 462ec1ba435eb4e5178f029efb836afdef9c9ccb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=462ec1ba435eb4e5178f029efb836afdef9c9ccb
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed Nov 7 15:55:26 2012 +0100
msi: Return correct length for the empty string from deformat_string.
---
dlls/msi/format.c | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/dlls/msi/format.c b/dlls/msi/format.c
index 033f69c..756c4d1 100644
--- a/dlls/msi/format.c
+++ b/dlls/msi/format.c
@@ -1023,24 +1023,23 @@ done:
}
/* wrapper to resist a need for a full rewrite right now */
-DWORD deformat_string( MSIPACKAGE *package, const WCHAR *ptr, WCHAR **data )
+DWORD deformat_string( MSIPACKAGE *package, const WCHAR *fmt, WCHAR **data )
{
- if (ptr)
- {
- DWORD len = 0;
- MSIRECORD *rec = MSI_CreateRecord( 1 );
-
- MSI_RecordSetStringW( rec, 0, ptr );
- MSI_FormatRecordW( package, rec, NULL, &len );
+ DWORD len;
+ MSIRECORD *rec;
- len++;
- *data = msi_alloc( len * sizeof(WCHAR) );
- if (len > 1) MSI_FormatRecordW( package, rec, *data, &len );
- else *data[0] = 0;
+ *data = NULL;
+ if (!fmt) return 0;
+ if (!(rec = MSI_CreateRecord( 1 ))) return 0;
+ MSI_RecordSetStringW( rec, 0, fmt );
+ MSI_FormatRecordW( package, rec, NULL, &len );
+ if (!(*data = msi_alloc( ++len * sizeof(WCHAR) )))
+ {
msiobj_release( &rec->hdr );
- return len;
+ return 0;
}
- *data = NULL;
- return 0;
+ MSI_FormatRecordW( package, rec, *data, &len );
+ msiobj_release( &rec->hdr );
+ return len;
}
More information about the wine-cvs
mailing list