fix: heap-allocate tinfl_decompressor to prevent stack overflow in renderDeflatedJson - #11
Merged
martinberlin merged 5 commits intoMay 29, 2026
Conversation
Copilot
AI
changed the title
[WIP] Implement payload decompression using miniz
Add DEFLATE payload decompression (type 0x0002) and fix portrait-mode coordinate space
May 29, 2026
…vent stack overflow
Copilot
AI
changed the title
Add DEFLATE payload decompression (type 0x0002) and fix portrait-mode coordinate space
fix: heap-allocate tinfl_decompressor to prevent stack overflow in renderDeflatedJson
May 29, 2026
martinberlin
approved these changes
May 29, 2026
martinberlin
left a comment
Owner
There was a problem hiding this comment.
Great implementation. Works as expected!
Added my own fork of Miniz since it was not prepared to be added as a component in ESP-IDF
martinberlin
marked this pull request as ready for review
May 29, 2026 20:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tinfl_decompress_mem_to_heapplaces atinfl_decompressorstruct (~34 KB) on the task stack. On constrained ESP32 tasks (e.g. a BLE receive task), this immediately overflows the stack, causing aStack protection faultpanic at the first call torenderDeflatedJson.Changes
src/FastJsonDL.cpp— Replaced thetinfl_decompress_mem_to_heapcall with an inline decompression loop that:mallocstinfl_decompressoron the heap instead of the stackreallocin the same pattern as the original helperStack usage of
renderDeflatedJsondrops from ~34 KB to a handful of pointer-sized locals.