diff --git a/expat/apply-clang-tidy.sh b/expat/apply-clang-tidy.sh index a17d823f..832ec9fe 100755 --- a/expat/apply-clang-tidy.sh +++ b/expat/apply-clang-tidy.sh @@ -35,6 +35,7 @@ cd "$(dirname "$(type -P "$0")")" checks_to_enable=( bugprone-narrowing-conversions bugprone-suspicious-string-compare + misc-no-recursion readability-avoid-const-params-in-decls readability-named-parameter ) diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index 783d4016..a1544f56 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -1015,9 +1015,10 @@ generate_hash_secret_salt(XML_Parser parser) { static unsigned long get_hash_secret_salt(XML_Parser parser) { - if (parser->m_parentParser != NULL) - return get_hash_secret_salt(parser->m_parentParser); - return parser->m_hash_secret_salt; + const XML_Parser rootParser = getRootParserOf(parser, NULL); + assert(! rootParser->m_parentParser); + + return rootParser->m_hash_secret_salt; } static enum XML_Error @@ -2017,12 +2018,14 @@ int XMLCALL XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) { if (parser == NULL) return 0; - if (parser->m_parentParser) - return XML_SetHashSalt(parser->m_parentParser, hash_salt); + + const XML_Parser rootParser = getRootParserOf(parser, NULL); + assert(! rootParser->m_parentParser); + /* block after XML_Parse()/XML_ParseBuffer() has been called */ - if (parserBusy(parser)) + if (parserBusy(rootParser)) return 0; - parser->m_hash_secret_salt = hash_salt; + rootParser->m_hash_secret_salt = hash_salt; return 1; }