lxml: fix fuzz_xml_parse (#7565)

This commit is contained in:
DavidKorczynski 2022-04-13 10:21:35 +01:00 committed by GitHub
parent 4f932b199b
commit bc05619b4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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)