Skip to content

Fix subdivide_infos stack overflow (alloca -> malloc)

Mitchell Hentges requested to merge mitchhentges/gtk:css-stack-overflow into main

If the amount of CSS is significant, it's possible for subdivide_infos to overflow the stack. This is caused by allocating the CSS rule selectors directly onto the stack in combination with the recursion of subdivide_infos.

This causes a stack overflow on Windows when using Libadwaita 1.4+, because Libadwaita has had a lot of CSS rules added.

This is more likely to happen on Windows than Linux because Windows has a smaller default stack size (1MB instead of 10MB)


By allocating on the heap instead of the stack, we significantly avoid the stack overflow risk.

Edited by Mitchell Hentges

Merge request reports