Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid crash on corrupt footer #99

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pyxdf/pyxdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import struct
import itertools
import gzip
from xml.etree.ElementTree import fromstring
from xml.etree.ElementTree import fromstring, ParseError
from collections import OrderedDict, defaultdict
import logging
from pathlib import Path
Expand Down Expand Up @@ -328,7 +328,13 @@ def load_xdf(
elif tag == 6:
# read [StreamFooter] chunk
xml_string = f.read(chunklen - 6)
streams[StreamId]["footer"] = _xml2dict(fromstring(xml_string))
try:
streams[StreamId]["footer"] = _xml2dict(fromstring(xml_string))
except ParseError as e:
logger.error(
f"found likely XDF file corruption ({e}), "
"ignoring corrupted XML element in footer."
)
elif tag == 4:
# read [ClockOffset] chunk
temp[StreamId].clock_times.append(
Expand Down