From 321d1cdc7d1c8259a65983861755962650daff32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 2 Nov 2020 19:59:24 +0100 Subject: [PATCH] particle/progress-bar: handle tag_for_name() failing --- particles/progress-bar.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/particles/progress-bar.c b/particles/progress-bar.c index d03931c..ad5c4cd 100644 --- a/particles/progress-bar.c +++ b/particles/progress-bar.c @@ -179,13 +179,13 @@ instantiate(const struct particle *particle, const struct tag_set *tags) { const struct private *p = particle->private; const struct tag *tag = tag_for_name(tags, p->tag); - assert(tag != NULL); - long value = tag->as_int(tag); - long min = tag->min(tag); - long max = tag->max(tag); + long value = tag != NULL ? tag->as_int(tag) : 0; + long min = tag != NULL ? tag->min(tag) : 0; + long max = tag != NULL ? tag->max(tag) : 0; - LOG_DBG("%s: value=%ld, min=%ld, max=%ld", tag->name(tag), value, min, max); + LOG_DBG("%s: value=%ld, min=%ld, max=%ld", + tag != NULL ? tag->name(tag) : "", value, min, max); long fill_count = max == min ? 0 : p->width * value / (max - min); long empty_count = p->width - fill_count; @@ -224,6 +224,9 @@ instantiate(const struct particle *particle, const struct tag_set *tags) exposable->expose = &expose; exposable->on_mouse = &on_mouse; + if (tag == NULL) + return exposable; + enum tag_realtime_unit rt = tag->realtime(tag); if (rt == TAG_REALTIME_NONE)