msi: Fix freed memory access and fix freeing of invalid pointer.

This commit is contained in:
Aleksey Bragin 2010-10-22 20:08:58 +04:00 committed by Alexandre Julliard
parent 8819ae1e66
commit 8c5718ec9d
1 changed files with 5 additions and 2 deletions

View File

@ -2083,7 +2083,7 @@ static UINT ITERATE_CostFinalizeConditions(MSIRECORD *row, LPVOID param)
VS_FIXEDFILEINFO *msi_get_disk_file_version( LPCWSTR filename ) VS_FIXEDFILEINFO *msi_get_disk_file_version( LPCWSTR filename )
{ {
static const WCHAR name[] = {'\\',0}; static const WCHAR name[] = {'\\',0};
VS_FIXEDFILEINFO *ret; VS_FIXEDFILEINFO *ptr, *ret;
LPVOID version; LPVOID version;
DWORD versize, handle; DWORD versize, handle;
UINT sz; UINT sz;
@ -2100,12 +2100,15 @@ VS_FIXEDFILEINFO *msi_get_disk_file_version( LPCWSTR filename )
GetFileVersionInfoW( filename, 0, versize, version ); GetFileVersionInfoW( filename, 0, versize, version );
if (!VerQueryValueW( version, name, (LPVOID *)&ret, &sz )) if (!VerQueryValueW( version, name, (LPVOID *)&ptr, &sz ))
{ {
msi_free( version ); msi_free( version );
return NULL; return NULL;
} }
ret = msi_alloc( sz );
memcpy( ret, ptr, sz );
msi_free( version ); msi_free( version );
return ret; return ret;
} }