-
Notifications
You must be signed in to change notification settings - Fork 103
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
Stack overflow from jas_image_writecmpt() #256
Comments
Thank your for the report and investigation!
The change was done in 5017d3a so is available since jasper 2.0.20
@MaxKellermann probably you know more about this. |
The problem is that |
Fixes stack overflow bug on Windows, where variable-length arrays are not available. Unlike VLAs, _alloca() calls accumulate, and calling it in every loop iteration is certainly a bad idea. Regression from commit 5017d3a Closes jasper-software#256
Thanks @MaxKellermann ! @dgr37 please give feedback here once you have tested. |
Thank you @jubalh and @MaxKellermann ! The change works perfectly for me. |
With jasper 2.0.23 I am having major problems with decompression of medium-sized jpeg2000 files, resulting in a stack overflow. These problems did not occur in jasper 2.0.19. For example, if I take the attached .jp2 file and do a decompression such as
jasper.exe --input "BACanonEos400D 003.jp2" --output test.jp2 --output-format jp2
stack memory is already exhausted and jasper crashes. Compiler is MSVC.
I noticed that the stack overflow arises from jas_image.c:534, jas_image_writecmpt(), where _alloca() is called explicitly to allocate memory on stack. Replacing this by a heap allocation, e.g. with jas_alloc2(), solves the problem. I attached a patch for this.
Is there a reason why stack is preferable here?
Thank you!
jas_image_writecmpt.zip
The text was updated successfully, but these errors were encountered: