From bcde9a5b4964aba50f65253e0f1aaa967a6f9e34 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 12 May 2024 05:27:43 +0100 Subject: [PATCH] lhp: assert if NULL css stack coming to lws_csp_px iwashiira on github https://github.com/warmcat/libwebsockets/issues/3140 found the html / css calculation could end up with NULL margin sizes. This causes an assert if we get this unacceptable situation as far as lws_csp_px() --- lib/misc/lhp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/misc/lhp.c b/lib/misc/lhp.c index 59a227d84..73fd663f6 100644 --- a/lib/misc/lhp.c +++ b/lib/misc/lhp.c @@ -312,14 +312,19 @@ lws_css_compute_cascaded_length(lhp_ctx_t *ctx, int ref, lhp_pstack_t *ps, const lws_fx_t * lws_csp_px(const lcsp_atr_t *a, lhp_pstack_t *ps) { - lhp_ctx_t *ctx = lws_container_of(ps->list.owner, lhp_ctx_t, stack); - const lws_display_font_t *f = ps->font; + lhp_ctx_t *ctx; + const lws_display_font_t *f; lws_fx_t t1, t2, t3; int ref; + assert(ps); + if (!a) return NULL; + ctx = lws_container_of(ps->list.owner, lhp_ctx_t, stack); + f = ps->font; + ref = lhp_prop_axis(a); switch (a->unit) {