Commit 4407ea63 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Make sure not to free a a pointer that has been modified.

Check that the text identifier doesn't contain invalid characters.
parent 0c2fcf2e
...@@ -179,22 +179,29 @@ static LPWSTR msi_get_deformatted_field( MSIPACKAGE *package, MSIRECORD *rec, in ...@@ -179,22 +179,29 @@ static LPWSTR msi_get_deformatted_field( MSIPACKAGE *package, MSIRECORD *rec, in
* Extract the {\style} string from the front of the text to display and * Extract the {\style} string from the front of the text to display and
* update the pointer. * update the pointer.
*/ */
static LPWSTR msi_dialog_get_style( LPWSTR *text ) static LPWSTR msi_dialog_get_style( LPCWSTR p, LPCWSTR *rest )
{ {
LPWSTR ret = NULL; LPWSTR ret = NULL;
LPWSTR p = *text, q; LPCWSTR q, i;
DWORD len; DWORD len;
if( !*text ) *rest = p;
if( !p )
return ret; return ret;
if( *p++ != '{' ) if( *p++ != '{' )
return ret; return ret;
q = strchrW( p, '}' ); q = strchrW( p, '}' );
if( !q ) if( !q )
return ret; return ret;
*text = ++q;
if( *p++ != '\\' ) if( *p++ != '\\' )
return ret; return ret;
/* little bit of sanity checking to stop us getting confused with RTF */
for( i=p; i<q; i++ )
if( *i == '}' || *i == '\\' )
return ret;
*rest = ++q;
len = q - p; len = q - p;
ret = msi_alloc( len*sizeof(WCHAR) ); ret = msi_alloc( len*sizeof(WCHAR) );
...@@ -299,7 +306,8 @@ static msi_control *msi_dialog_create_window( msi_dialog *dialog, ...@@ -299,7 +306,8 @@ static msi_control *msi_dialog_create_window( msi_dialog *dialog,
DWORD style, HWND parent ) DWORD style, HWND parent )
{ {
DWORD x, y, width, height; DWORD x, y, width, height;
LPWSTR font = NULL, title = NULL; LPWSTR font = NULL, title_font = NULL;
LPCWSTR title = NULL;
msi_control *control; msi_control *control;
style |= WS_CHILD; style |= WS_CHILD;
...@@ -327,8 +335,8 @@ static msi_control *msi_dialog_create_window( msi_dialog *dialog, ...@@ -327,8 +335,8 @@ static msi_control *msi_dialog_create_window( msi_dialog *dialog,
if( text ) if( text )
{ {
deformat_string( dialog->package, text, &title ); deformat_string( dialog->package, text, &title_font );
font = msi_dialog_get_style( &title ); font = msi_dialog_get_style( title_font, &title );
} }
control->hwnd = CreateWindowW( szCls, title, style, control->hwnd = CreateWindowW( szCls, title, style,
...@@ -340,8 +348,8 @@ static msi_control *msi_dialog_create_window( msi_dialog *dialog, ...@@ -340,8 +348,8 @@ static msi_control *msi_dialog_create_window( msi_dialog *dialog,
msi_dialog_set_font( dialog, control->hwnd, msi_dialog_set_font( dialog, control->hwnd,
font ? font : dialog->default_font ); font ? font : dialog->default_font );
msi_free( title_font );
msi_free( font ); msi_free( font );
msi_free( title );
return control; return control;
} }
...@@ -1056,16 +1064,16 @@ msi_maskedit_create_children( struct msi_maskedit_info *info, LPCWSTR font ) ...@@ -1056,16 +1064,16 @@ msi_maskedit_create_children( struct msi_maskedit_info *info, LPCWSTR font )
/* office 2003 uses "73931<````=````=````=````=`````>@@@@@" */ /* office 2003 uses "73931<````=````=````=````=`````>@@@@@" */
static UINT msi_dialog_maskedit_control( msi_dialog *dialog, MSIRECORD *rec ) static UINT msi_dialog_maskedit_control( msi_dialog *dialog, MSIRECORD *rec )
{ {
LPWSTR mask, title = NULL, val = NULL, font; LPWSTR font_mask, val = NULL, font;
struct msi_maskedit_info *info = NULL; struct msi_maskedit_info *info = NULL;
UINT ret = ERROR_SUCCESS; UINT ret = ERROR_SUCCESS;
msi_control *control; msi_control *control;
LPCWSTR prop; LPCWSTR prop, mask;
TRACE("\n"); TRACE("\n");
mask = msi_get_deformatted_field( dialog->package, rec, 10 ); font_mask = msi_get_deformatted_field( dialog->package, rec, 10 );
font = msi_dialog_get_style( &mask ); font = msi_dialog_get_style( font_mask, &mask );
if( !mask ) if( !mask )
{ {
ERR("mask template is empty\n"); ERR("mask template is empty\n");
...@@ -1117,8 +1125,8 @@ static UINT msi_dialog_maskedit_control( msi_dialog *dialog, MSIRECORD *rec ) ...@@ -1117,8 +1125,8 @@ static UINT msi_dialog_maskedit_control( msi_dialog *dialog, MSIRECORD *rec )
end: end:
if( ret != ERROR_SUCCESS ) if( ret != ERROR_SUCCESS )
msi_free( info ); msi_free( info );
msi_free( title ); msi_free( font_mask );
msi_free( mask ); msi_free( font );
return ret; return ret;
} }
......
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