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

PngDecoder supports setting limits via with_limits but not via set_limits #2084

Open
Shnatsel opened this issue Jan 4, 2024 · 0 comments
Open

Comments

@Shnatsel
Copy link
Contributor

Shnatsel commented Jan 4, 2024

This happens in image v0.24.7.

Expected

PngDecoder should support setting memory limits via the generic set_limits method, not only via its own with_limits method.

Actual behaviour

Only the with_limits constructor sets limits correctly; setting limits via set_limits is not implemented.

Quoting @fintelia :

PngDecoder should also be changed. But sadly we can't support set_limits there without a breaking change.

The issue is a subtle problem with the type signature of PngDecoder::is_apng that doesn't let us return limit or parsing errors. Instead we have to do metadata parsing ahead of time in new/with_limits so that we can report those errors. But once we've parsed the metadata the crate doesn't let us set the allocation limit (and that's the correct approach because we want to use the limit to avoid allocating an unbounded amount of space for storing metadata!)

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

No branches or pull requests

1 participant