mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Fix memory leaks in unit-test
* hsts.c (get_hsts_store_filename): Free the homedir value (close_hsts_test_store): Actually free the store struct too (test_hsts_new_entry): Pass store to close_hsts_test_store() (test_hsts_url_rewrite_superdomain): Same (test_hsts_url_rewrite_congruent): Same (test_hsts_read_database): Same and homedir and store filename * http.c (test_parse_content_disposition): Free the returned filename * url.c (test_append_uri_pathel): Free allocated string
This commit is contained in:
parent
5c4489db9b
commit
6b5acff566
13
src/hsts.c
13
src/hsts.c
@ -558,6 +558,7 @@ get_hsts_store_filename (void)
|
|||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xfree (home);
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,13 +576,14 @@ open_hsts_test_store (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
close_hsts_test_store (void)
|
close_hsts_test_store (hsts_store_t store)
|
||||||
{
|
{
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
|
|
||||||
filename = get_hsts_store_filename ();
|
filename = get_hsts_store_filename ();
|
||||||
unlink (filename);
|
unlink (filename);
|
||||||
xfree (filename);
|
xfree (filename);
|
||||||
|
xfree (store);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
@ -658,7 +660,7 @@ test_hsts_new_entry (void)
|
|||||||
mu_assert("Should've been no match", match == NO_MATCH);
|
mu_assert("Should've been no match", match == NO_MATCH);
|
||||||
|
|
||||||
hsts_store_close (s);
|
hsts_store_close (s);
|
||||||
close_hsts_test_store ();
|
close_hsts_test_store (s);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -679,7 +681,7 @@ test_hsts_url_rewrite_superdomain (void)
|
|||||||
TEST_URL_RW (s, "bar.www.foo.com", 80);
|
TEST_URL_RW (s, "bar.www.foo.com", 80);
|
||||||
|
|
||||||
hsts_store_close (s);
|
hsts_store_close (s);
|
||||||
close_hsts_test_store ();
|
close_hsts_test_store (s);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -700,7 +702,7 @@ test_hsts_url_rewrite_congruent (void)
|
|||||||
TEST_URL_NORW (s, "www.foo.com", 80);
|
TEST_URL_NORW (s, "www.foo.com", 80);
|
||||||
|
|
||||||
hsts_store_close (s);
|
hsts_store_close (s);
|
||||||
close_hsts_test_store ();
|
close_hsts_test_store (s);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -736,8 +738,11 @@ test_hsts_read_database (void)
|
|||||||
TEST_URL_RW (table, "test.example.com", 8080);
|
TEST_URL_RW (table, "test.example.com", 8080);
|
||||||
|
|
||||||
hsts_store_close (table);
|
hsts_store_close (table);
|
||||||
|
close_hsts_test_store (table);
|
||||||
unlink (file);
|
unlink (file);
|
||||||
}
|
}
|
||||||
|
xfree (file);
|
||||||
|
xfree (home);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4926,6 +4926,7 @@ filename*1=\"B\"", "AA.ext", true },
|
|||||||
res == test_array[i].result
|
res == test_array[i].result
|
||||||
&& (res == false
|
&& (res == false
|
||||||
|| 0 == strcmp (test_array[i].filename, filename)));
|
|| 0 == strcmp (test_array[i].filename, filename)));
|
||||||
|
xfree (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2350,6 +2350,7 @@ test_append_uri_pathel(void)
|
|||||||
|
|
||||||
mu_assert ("test_append_uri_pathel: wrong result",
|
mu_assert ("test_append_uri_pathel: wrong result",
|
||||||
strcmp (dest.base, test_array[i].expected_result) == 0);
|
strcmp (dest.base, test_array[i].expected_result) == 0);
|
||||||
|
xfree (dest.base);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user