Skip to content

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