cabinet: Fix several file list leaks in the extract tests.

This commit is contained in:
James Hawkins 2010-01-06 18:27:05 -08:00 committed by Alexandre Julliard
parent ced5081eb9
commit 300cc0fea1

View file

@ -329,6 +329,26 @@ static BOOL check_list(struct FILELIST **node, const char *filename, BOOL do_ext
return TRUE;
}
static void free_file_node(struct FILELIST *node)
{
HeapFree(GetProcessHeap(), 0, node->FileName);
HeapFree(GetProcessHeap(), 0, node);
}
static void free_file_list(SESSION* session)
{
struct FILELIST *next, *curr = session->FileList;
while (curr)
{
next = curr->next;
free_file_node(curr);
curr = next;
}
session->FileList = NULL;
}
static void test_Extract(void)
{
SESSION session;
@ -370,6 +390,7 @@ static void test_Extract(void)
ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
free_file_list(&session);
/* try fill file list operation */
ZeroMemory(&session, sizeof(SESSION));
@ -454,7 +475,10 @@ static void test_Extract(void)
ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
/* remove two of the files in the list */
node = session.FileList->next;
session.FileList->next = session.FileList->next->next;
free_file_node(node);
free_file_node(session.FileList->next->next);
session.FileList->next->next = NULL;
session.FilterList = NULL;
CreateDirectoryA("dest", NULL);
@ -482,6 +506,7 @@ static void test_Extract(void)
ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
ok(!check_list(&node, "a.txt", FALSE), "list entry wrong\n");
free_file_list(&session);
session.Operation = EXTRACT_FILLFILELIST;
session.FileList = NULL;
@ -564,6 +589,7 @@ static void test_Extract(void)
ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
free_file_list(&session);
/* cabinet does not exist */
ZeroMemory(&session, sizeof(SESSION));
@ -593,6 +619,7 @@ static void test_Extract(void)
ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry should not exist\n");
ok(!check_list(&node, "b.txt", FALSE), "list entry should not exist\n");
ok(!check_list(&node, "a.txt", FALSE), "list entry should not exist\n");
free_file_list(&session);
/* first file exists */
createTestFile("dest\\a.txt");
@ -631,6 +658,7 @@ static void test_Extract(void)
ok(!check_list(&node, "b.txt", FALSE), "list entry should not exist\n");
}
ok(!check_list(&node, "a.txt", FALSE), "list entry should not exist\n");
free_file_list(&session);
SetFileAttributesA("dest\\a.txt", FILE_ATTRIBUTE_NORMAL);
DeleteFileA("dest\\a.txt");
@ -670,7 +698,8 @@ static void test_Extract(void)
ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n");
ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
ok(!check_list(&node, "b.txt", FALSE), "list entry wrong\n");
ok(check_list(&node, "a.txt", TRUE), "list entry wrong\n");
ok(!check_list(&node, "a.txt", TRUE), "list entry wrong\n");
free_file_list(&session);
SetFileAttributesA("dest\\testdir\\c.txt", FILE_ATTRIBUTE_NORMAL);
DeleteFileA("dest\\testdir\\c.txt");