Skip to content

check for cycles during indirect reference resolution#1097

Merged
EliotJones merged 1 commit intoUglyToad:masterfrom
jan-sutter:master
Jul 20, 2025
Merged

check for cycles during indirect reference resolution#1097
EliotJones merged 1 commit intoUglyToad:masterfrom
jan-sutter:master

Conversation

@jan-sutter
Copy link
Copy Markdown
Contributor

This PR "fixes" #1096

Copy link
Copy Markdown
Member

@EliotJones EliotJones left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! This looks like a reasonable fix, the only concern I have is whether reference generation number is needed in the lookup set too, but I think that's such an edge case as to be virtually impossible. Let's merge it and see if the integration tests all pass. I'll close the issue you raised alongside this since this PR should address it.

@EliotJones EliotJones merged commit e636212 into UglyToad:master Jul 20, 2025
2 checks passed
@BobLd
Copy link
Copy Markdown
Collaborator

BobLd commented Jul 20, 2025

@jan-sutter thanks a lot for opening the issue and creating a PR. I think the current approach would add non negligible overhead. Is there no other way to achieve a similar approach than maintaining a collection?

I'll have a look too on my side and let you know

@EliotJones
Copy link
Copy Markdown
Member

EliotJones commented Jul 20, 2025

Sorry @BobLd I jumped the gun here, I'm not sure there is a better fix to be honest without much more rework. We're already quite heavy on object creation so I imagine the performance impact in non-negligible but also not much beyond baseline. The problem with these recursive functions that can loop is you always need some way to break out of an invalid file, the other alternative would be pass a counter integer and just throw if it exceeds some max-val iterations but I think this approach allows us to parse the file rather than throwing which is a nicer fix.

@BobLd
Copy link
Copy Markdown
Collaborator

BobLd commented Jul 20, 2025

@EliotJones makes sense - I've created #1101 to track the full IndirectReference instead of just the ObjectNumber

@theolivenbaum
Copy link
Copy Markdown
Contributor

Minor comment, but shouldn't this be checked using a HashSet instead of a list?

@BobLd
Copy link
Copy Markdown
Collaborator

BobLd commented Jul 26, 2025

@theolivenbaum 100% agreed, you can either create a PR or ill push the change shortly

@theolivenbaum
Copy link
Copy Markdown
Contributor

Perfect, I'll send a PR in a bit then!

@theolivenbaum
Copy link
Copy Markdown
Contributor

Done: #1112

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.

4 participants