From bc05619b4c762d502e7d35557bdd4d1b1670bc80 Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Wed, 13 Apr 2022 10:21:35 +0100 Subject: [PATCH] lxml: fix fuzz_xml_parse (#7565) --- projects/lxml/fuzz_xml_parse.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/lxml/fuzz_xml_parse.py b/projects/lxml/fuzz_xml_parse.py index ecf90883f..e5e616b02 100644 --- a/projects/lxml/fuzz_xml_parse.py +++ b/projects/lxml/fuzz_xml_parse.py @@ -22,17 +22,25 @@ with atheris.instrument_imports(): def TestOneInput(data): + tree = None + success = False try: root = et.XML(data) if root != None: et.indent(root) tree = et.ElementTree(root) - a = et.Element("a") - tree.getelementpath(a) + success = True except et.XMLSyntaxError: None + if success: + try: + a = et.Element("a") + tree.getelementpath(a) + except ValueError: + None + def main(): atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)