Hans Leidekker : msi: Fix handling of strings with embedded nulls in msi_addstring.
Alexandre Julliard
julliard at winehq.org
Mon Nov 5 13:32:25 CST 2012
Module: wine
Branch: master
Commit: 8d21f998c3c7fd4e469fab81229f07eb763cd6ee
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8d21f998c3c7fd4e469fab81229f07eb763cd6ee
Author: Hans Leidekker <hans at codeweavers.com>
Date: Mon Nov 5 16:29:30 2012 +0100
msi: Fix handling of strings with embedded nulls in msi_addstring.
---
dlls/msi/string.c | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/dlls/msi/string.c b/dlls/msi/string.c
index 486cdf9..8e3e575 100644
--- a/dlls/msi/string.c
+++ b/dlls/msi/string.c
@@ -258,14 +258,12 @@ static UINT msi_string2idA( const string_table *st, LPCSTR buffer, UINT *id )
return r;
}
-static int msi_addstring( string_table *st, UINT n, const CHAR *data, int len, USHORT refcount, enum StringPersistence persistence )
+static int msi_addstring( string_table *st, UINT n, const char *data, UINT len, USHORT refcount, enum StringPersistence persistence )
{
LPWSTR str;
int sz;
- if( !data )
- return 0;
- if( !data[0] )
+ if( !data || !len )
return 0;
if( n > 0 )
{
@@ -295,8 +293,6 @@ static int msi_addstring( string_table *st, UINT n, const CHAR *data, int len, U
}
/* allocate a new string */
- if( len < 0 )
- len = strlen(data);
sz = MultiByteToWideChar( st->codepage, 0, data, len, NULL, 0 );
str = msi_alloc( (sz+1)*sizeof(WCHAR) );
if( !str )
@@ -305,7 +301,6 @@ static int msi_addstring( string_table *st, UINT n, const CHAR *data, int len, U
str[sz] = 0;
set_st_entry( st, n, str, sz, refcount, persistence );
-
return n;
}
@@ -316,6 +311,9 @@ int msi_addstringW( string_table *st, const WCHAR *data, int len, USHORT refcoun
if( !data )
return 0;
+
+ if (len < 0) len = strlenW( data );
+
if( !data[0] && !len )
return 0;
@@ -333,8 +331,6 @@ int msi_addstringW( string_table *st, const WCHAR *data, int len, USHORT refcoun
return -1;
/* allocate a new string */
- if(len<0)
- len = strlenW(data);
TRACE( "%s, n = %d len = %d\n", debugstr_wn(data, len), n, len );
str = msi_alloc( (len+1)*sizeof(WCHAR) );
@@ -344,7 +340,6 @@ int msi_addstringW( string_table *st, const WCHAR *data, int len, USHORT refcoun
str[len] = 0;
set_st_entry( st, n, str, len, refcount, persistence );
-
return n;
}
More information about the wine-cvs
mailing list