commit 442ba99ada4c0d765ba4f2724ba525d156c637f9
parent 29896e2ac6458fc60657adbacf2adb15f31035df
Author: default <nobody@localhost>
Date: Tue, 29 Aug 2023 19:38:53 +0200
Minor tweak to avoid possible undefined behaviour.
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/html.c b/html.c
@@ -1147,10 +1147,12 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
/* not a list */
tag = xs_list_new();
tag = xs_list_append(tag, p);
- } else {
- /* is a list */
- tag = xs_dup(p);
}
+ else
+ if (xs_type(p) == XSTYPE_LIST)
+ tag = xs_dup(p);
+ else
+ tag = xs_list_new();
xs_list *tags = tag;
@@ -1291,7 +1293,10 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
attach = xs_list_append(attach, v);
}
else
+ if (xs_type(v) == XSTYPE_LIST)
attach = xs_dup(v);
+ else
+ attach = xs_list_new();
/* does the message have an image? */
if (xs_type(v = xs_dict_get(msg, "image")) == XSTYPE_DICT) {