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

Replaced assumption about padding by just searching for the start of … #790

Closed

Conversation

MartinStellmacher
Copy link

…the next frame by the help of the 'LOBJ' mark.

#786

…the next frame by the help of the 'LOBJ' mark.
Comment on lines +223 to +230
#fix padding
if pos + obj_header_base_size > max_pos:
# This object continues in the next container
return
for i in range(4):
if data[pos+i:pos+i+4] == b"LOBJ":
break
pos += i
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using the index method instead since it is implemented in optimized C. It should also handle the case when LOBJ is split up in two containers.

Suggested change
#fix padding
if pos + obj_header_base_size > max_pos:
# This object continues in the next container
return
for i in range(4):
if data[pos+i:pos+i+4] == b"LOBJ":
break
pos += i
# Find next object after padding (depends on object type)
try:
pos = data.index(b"LOBJ", pos, pos + 8)
except ValueError:
if pos + 8 > max_pos:
# Not enough data in container
return
raise BLFParseError("Could not find next object")

You would then also need to change line 178 to remove memoryview but that does not seem affect performance much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants