Module: wine Branch: master Commit: 300cc0fea1ab3570a673c701c1f4662621968d1c URL: http://source.winehq.org/git/wine.git/?a=commit;h=300cc0fea1ab3570a673c701c1...
Author: James Hawkins truiken@gmail.com Date: Wed Jan 6 18:27:05 2010 -0800
cabinet: Fix several file list leaks in the extract tests.
---
dlls/cabinet/tests/extract.c | 31 ++++++++++++++++++++++++++++++- 1 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/dlls/cabinet/tests/extract.c b/dlls/cabinet/tests/extract.c index c0a0c92..76bd7b7 100644 --- a/dlls/cabinet/tests/extract.c +++ b/dlls/cabinet/tests/extract.c @@ -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");