particle/map: return NULL if we neither find a matching tag, nor have a default tag

This commit is contained in:
Daniel Eklöf 2020-10-30 16:25:55 +01:00
parent 4d05947985
commit 1e5a1d0341
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -87,11 +87,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 || p->default_particle != NULL);
if (tag == NULL)
return p->default_particle->instantiate(p->default_particle, tags);
if (tag == NULL) {
if (p->default_particle != NULL)
return p->default_particle->instantiate(p->default_particle, tags);
else
return NULL;
}
const char *tag_value = tag->as_string(tag);
struct particle *pp = NULL;