diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-04-12 22:51:01 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-04-12 22:53:48 -0400 |
commit | c66b030427e6540ebf324e0925e5c3e655c518c9 (patch) | |
tree | 996060b57482050c6a7892222effb01b4f76502d | |
parent | 442f485591b65185538ab941b58743cadd1d2092 (diff) | |
download | gtk+-c66b030427e6540ebf324e0925e5c3e655c518c9.tar.gz |
ngl: Fix a rare assertion violationngl-crash
When we clean up the uniform allocations after a frame,
it can happen that our space requirements actually increase,
due to padding that depends on the order of allocations.
Instead of asserting that it doesn't happen, just make
it work by growing our allocation.
Fixes: #3853
-rw-r--r-- | gsk/ngl/gskngluniformstate.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gsk/ngl/gskngluniformstate.c b/gsk/ngl/gskngluniformstate.c index 44270e8fa5..9a70088779 100644 --- a/gsk/ngl/gskngluniformstate.c +++ b/gsk/ngl/gskngluniformstate.c @@ -215,7 +215,17 @@ gsk_ngl_uniform_state_end_frame (GskNglUniformState *state) state->values_pos = allocator; - g_assert (allocator <= state->values_len); + /* It can happen that our space requirements grow due to + * difference in order increasing padding. As a pragmatic + * solution to this, just increase the allocation to cover + * the predefined mappins. + */ + if (allocator > state->values_len) + { + while (allocator > state->values_len) + state->values_len *= 2; + state->values_buf = g_realloc (state->values_buf, state->values_len); + } memset (state->apply_hash, 0, sizeof state->apply_hash); } |