Commit f86cfd40 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

msi: Avoid a memory leak by freeing actions scripts in one place only.

parent f5dddd55
...@@ -1491,14 +1491,10 @@ static UINT execute_script(MSIPACKAGE *package, UINT script ) ...@@ -1491,14 +1491,10 @@ static UINT execute_script(MSIPACKAGE *package, UINT script )
ui_actionstart(package, action); ui_actionstart(package, action);
TRACE("Executing Action (%s)\n",debugstr_w(action)); TRACE("Executing Action (%s)\n",debugstr_w(action));
rc = ACTION_PerformAction(package, action, TRUE); rc = ACTION_PerformAction(package, action, TRUE);
msi_free(package->script->Actions[script][i]);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
break; break;
} }
msi_free(package->script->Actions[script]); msi_free_action_script(package, script);
package->script->ActionCount[script] = 0;
package->script->Actions[script] = NULL;
return rc; return rc;
} }
......
...@@ -384,6 +384,17 @@ UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action) ...@@ -384,6 +384,17 @@ UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action)
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
void msi_free_action_script(MSIPACKAGE *package, UINT script)
{
int i;
for (i = 0; i < package->script->ActionCount[script]; i++)
msi_free(package->script->Actions[script][i]);
msi_free(package->script->Actions[script]);
package->script->Actions[script] = NULL;
package->script->ActionCount[script] = 0;
}
static void remove_tracked_tempfiles(MSIPACKAGE* package) static void remove_tracked_tempfiles(MSIPACKAGE* package)
{ {
struct list *item, *cursor; struct list *item, *cursor;
...@@ -571,13 +582,7 @@ void ACTION_free_package_structures( MSIPACKAGE* package) ...@@ -571,13 +582,7 @@ void ACTION_free_package_structures( MSIPACKAGE* package)
if (package->script) if (package->script)
{ {
for (i = 0; i < TOTAL_SCRIPTS; i++) for (i = 0; i < TOTAL_SCRIPTS; i++)
{ msi_free_action_script(package, i);
int j;
for (j = 0; j < package->script->ActionCount[i]; j++)
msi_free(package->script->Actions[i][j]);
msi_free(package->script->Actions[i]);
}
for (i = 0; i < package->script->UniqueActionsCount; i++) for (i = 0; i < package->script->UniqueActionsCount; i++)
msi_free(package->script->UniqueActions[i]); msi_free(package->script->UniqueActions[i]);
......
...@@ -752,6 +752,7 @@ extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file ); ...@@ -752,6 +752,7 @@ extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir ); extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
extern int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path); extern int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path);
extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action); extern UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action);
extern void msi_free_action_script(MSIPACKAGE *package, UINT script);
extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR); extern LPWSTR build_icon_path(MSIPACKAGE *, LPCWSTR);
extern LPWSTR build_directory_name(DWORD , ...); extern LPWSTR build_directory_name(DWORD , ...);
extern BOOL create_full_pathW(const WCHAR *path); extern BOOL create_full_pathW(const WCHAR *path);
......
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