tests: Exit parser_stop_character_handler if parser is finished

When test_repeated_stop_parser_between_char_data_calls runs without
chunking the input -- which I am about to do in my next commit -- the
parser_stop_character_handler callback happens multiple times. This is
because stopping the parser doesn't stop all callbacks immediately,
which is valid (documented) behavior.

The second callback tried to stop the parser again, getting unexpected
errors. Let's check the parser status on entry and return early if it's
already finished.
This commit is contained in:
Snild Dolkow 2023-09-26 12:29:05 +02:00
parent e1dc3383e3
commit b4d2b76a97

View file

@ -1573,6 +1573,11 @@ parser_stop_character_handler(void *userData, const XML_Char *s, int len) {
UNUSED_P(userData);
UNUSED_P(s);
UNUSED_P(len);
XML_ParsingStatus status;
XML_GetParsingStatus(g_parser, &status);
if (status.parsing == XML_FINISHED) {
return; // the parser was stopped by a previous call to this handler.
}
XML_StopParser(g_parser, g_resumable);
XML_SetCharacterDataHandler(g_parser, NULL);
if (! g_resumable) {