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

This commit is contained in:
Mike McCormack 2006-11-02 18:12:43 +09:00 committed by Alexandre Julliard
parent f5dddd557f
commit f86cfd4088
3 changed files with 14 additions and 12 deletions

View File

@ -1491,14 +1491,10 @@ static UINT execute_script(MSIPACKAGE *package, UINT script )
ui_actionstart(package, action);
TRACE("Executing Action (%s)\n",debugstr_w(action));
rc = ACTION_PerformAction(package, action, TRUE);
msi_free(package->script->Actions[script][i]);
if (rc != ERROR_SUCCESS)
break;
}
msi_free(package->script->Actions[script]);
package->script->ActionCount[script] = 0;
package->script->Actions[script] = NULL;
msi_free_action_script(package, script);
return rc;
}

View File

@ -384,6 +384,17 @@ UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action)
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)
{
struct list *item, *cursor;
@ -571,13 +582,7 @@ void ACTION_free_package_structures( MSIPACKAGE* package)
if (package->script)
{
for (i = 0; i < TOTAL_SCRIPTS; 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]);
}
msi_free_action_script(package, i);
for (i = 0; i < package->script->UniqueActionsCount; i++)
msi_free(package->script->UniqueActions[i]);

View File

@ -752,6 +752,7 @@ extern MSIFILE *get_loaded_file( MSIPACKAGE* package, LPCWSTR file );
extern MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir );
extern int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path);
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_directory_name(DWORD , ...);
extern BOOL create_full_pathW(const WCHAR *path);