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

[RFC] resolve a recursion bug in ObjectHash#deref! #195

Closed
wants to merge 2 commits into from

Conversation

yob
Copy link
Owner

@yob yob commented Jan 22, 2017

This removes special handling of Stream objects from ObjectHash#deref!.

deref! was added in 9c520b6 and attempts to return a deep object graph that contains no PDF::Reader::Reference objects and can be walked without risk of needing to refer back to the associated ObjectHash instance.

This change resolves a recursion bug that can occur in real world files, but it also weakens the guarantee that the returned object graph can be used without the ObjectHash. It's possible that the returned graph will contain a PDF::Reader::Stream instance that contains some PDF::Reader::Reference objects.

I'm not yet convinced that this is the right solution - but the build is green and it's an option open to us. This would be a breaking change to a public API, and although our build is green it may impact users.

@yob
Copy link
Owner Author

yob commented Jan 22, 2017

This is one option that would resolve the issues reported in #51 and #94.

yob added 2 commits February 7, 2017 22:50
This single page PDF has a Form XObject in its Resources dict. The Form
XObject has its own Resources dict, which has an XObject pointing to
itself.

Nested XObjects are fine, but not recursive ones.

This is a simpler file that demonstrates an issue originally found in
the PDF provided at [1]

[1] #94 (comment)
* deref! was added in 9c520b6 and attempts to return a deep object graph
  that contains no PDF::Reader::Reference objects and can be walked
  without risk of needing to refer back to the associated ObjectHash
  instance
* This change resolves a recursion bug that can occur in real world
  files, but it also weakens the guarantee that the returned object
  graph can be used without the ObjectHash. It's possible that the
  returned graph will contain a PDF::Reader::Stream instance that contains
  some PDF::Reader::Reference objects.
* I'm not yet convinced that this is the right solution - but the build
  is green and it's an option open to us.
@yob yob force-pushed the recursive-form-xobject branch from 853b28b to 7f5a023 Compare February 7, 2017 11:54
@yob yob mentioned this pull request Feb 12, 2017
@yob
Copy link
Owner Author

yob commented Feb 12, 2017

I decided to merge an alternate solution - see #198

@yob yob closed this Feb 12, 2017
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.

1 participant