diff --git a/dlls/msi/action.c b/dlls/msi/action.c index ff4c0e1a148..b51bd199e22 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -423,6 +423,47 @@ void ACTION_remove_tracked_tempfiles(MSIPACKAGE* package) } } +/* Called when the package is being closed */ +extern void ACTION_free_package_structures( MSIPACKAGE* package) +{ + INT i; + + TRACE("Freeing package action data\n"); + + /* No dynamic buffers in features */ + if (package->features && package->loaded_features > 0) + HeapFree(GetProcessHeap(),0,package->features); + + for (i = 0; i < package->loaded_folders; i++) + { + HeapFree(GetProcessHeap(),0,package->folders[i].Directory); + HeapFree(GetProcessHeap(),0,package->folders[i].TargetDefault); + HeapFree(GetProcessHeap(),0,package->folders[i].SourceDefault); + HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedTarget); + HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedSource); + HeapFree(GetProcessHeap(),0,package->folders[i].Property); + } + if (package->folders && package->loaded_folders > 0) + HeapFree(GetProcessHeap(),0,package->folders); + + /* no dynamic buffers in components */ + if (package->components && package->loaded_components > 0) + HeapFree(GetProcessHeap(),0,package->components); + + for (i = 0; i < package->loaded_files; i++) + { + HeapFree(GetProcessHeap(),0,package->files[i].File); + HeapFree(GetProcessHeap(),0,package->files[i].FileName); + HeapFree(GetProcessHeap(),0,package->files[i].Version); + HeapFree(GetProcessHeap(),0,package->files[i].Language); + HeapFree(GetProcessHeap(),0,package->files[i].SourcePath); + HeapFree(GetProcessHeap(),0,package->files[i].TargetPath); + } + + if (package->files && package->loaded_files > 0) + HeapFree(GetProcessHeap(),0,package->files); +} + static UINT ACTION_OpenQuery( MSIDATABASE *db, MSIQUERY **view, LPCWSTR fmt, ... ) { LPWSTR szQuery; diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 135b3e78f67..5475047d288 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -273,6 +273,7 @@ extern UINT read_raw_stream_data( MSIDATABASE*, LPCWSTR stname, USHORT **pdata, UINT *psz ); extern UINT ACTION_DoTopLevelINSTALL( MSIPACKAGE *, LPCWSTR, LPCWSTR ); extern void ACTION_remove_tracked_tempfiles( MSIPACKAGE* ); +extern void ACTION_free_package_structures( MSIPACKAGE* ); /* record internals */ extern UINT MSI_RecordSetIStream( MSIRECORD *, unsigned int, IStream *); diff --git a/dlls/msi/package.c b/dlls/msi/package.c index 381affcfe58..cd54f61c7f1 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -53,18 +53,8 @@ void MSI_FreePackage( MSIOBJECTHDR *arg) MSIPACKAGE *package= (MSIPACKAGE*) arg; ACTION_remove_tracked_tempfiles(package); + ACTION_free_package_structures(package); - if (package->features && package->loaded_features > 0) - HeapFree(GetProcessHeap(),0,package->features); - - if (package->folders && package->loaded_folders > 0) - HeapFree(GetProcessHeap(),0,package->folders); - - if (package->components && package->loaded_components > 0) - HeapFree(GetProcessHeap(),0,package->components); - - if (package->files && package->loaded_files > 0) - HeapFree(GetProcessHeap(),0,package->files); msiobj_release( &package->db->hdr ); }