mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-15 00:38:15 +00:00
Test XML_SetEncoding against memory allocation failures
This commit is contained in:
parent
d0c57b2a29
commit
36fb006a34
1 changed files with 18 additions and 0 deletions
|
@ -2554,6 +2554,23 @@ START_TEST(test_alloc_dtd_default_handling)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
/* Test robustness of XML_SetEncoding() with a failing allocator */
|
||||
START_TEST(test_alloc_explicit_encoding)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
allocation_count = i;
|
||||
if (XML_SetEncoding(parser, "us-ascii") == XML_STATUS_OK)
|
||||
break;
|
||||
}
|
||||
if (i == 0)
|
||||
fail("Encoding set despite failing allocator");
|
||||
else if (i == 5)
|
||||
fail("Encoding not set at allocation count 5");
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
static Suite *
|
||||
make_suite(void)
|
||||
|
@ -2655,6 +2672,7 @@ make_suite(void)
|
|||
tcase_add_test(tc_alloc, test_alloc_external_entity);
|
||||
tcase_add_test(tc_alloc, test_alloc_internal_entity);
|
||||
tcase_add_test(tc_alloc, test_alloc_dtd_default_handling);
|
||||
tcase_add_test(tc_alloc, test_alloc_explicit_encoding);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue