POSIX strndup() does not read memory beyond NUL byte of the source
string. Preserve this behavior in libexpat implementation to prevent
access violations and keep portability.
Please see commit 60dffa148c
("tests: Use normal XML_Parse in test_suspend_resume_internal_entity")
for more details on the related issue.
In reaction to analysis by Berkay Eren Ürün.
The key is to have __attribute__((noreturn)) somewhere that clang-tidy
can see it. In this case, this is the _fail() function, which is
conditionally called from the assert_true() macro.
This will ensure that clang-tidy doesn't complain about NULL values
that we've asserted against in tests.
The _XML_Parse_SINGLE_BYTES function currently calls XML_Parse() one
byte at a time. This is useful to detect possible parsing bugs related
to having to exit parsing, wait for more data, and resume.
This commit makes SINGLE_BYTES even more useful by repeating all tests,
changing the chunk size every time. So instead of just one byte at a
time, we now also test two bytes at a time, and so on. Tests that don't
use the SINGLE_BYTES also run multiple times, but are otherwise not
affected.
This uncovered some issues, which have been fixed in preceding commits.
On failure, the chunk size is included in the "FAIL" log prints.
Also make the control variables int rather than intptr_t. They
were previously typed for convenience of passing them as a user
data "pointer", but that's much less convenient when they are
externally linked.