From: Andrew Lewis Date: Fri, 15 Jul 2022 11:26:10 +0000 (+0200) Subject: [Minor] rspamc: fix crash on non-string element in `messages` X-Git-Tag: 3.3~131^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F4214%2Fhead;p=rspamd.git [Minor] rspamc: fix crash on non-string element in `messages` --- diff --git a/src/client/rspamc.cxx b/src/client/rspamc.cxx index 3615d3be5..cb847bf5b 100644 --- a/src/client/rspamc.cxx +++ b/src/client/rspamc.cxx @@ -1030,8 +1030,16 @@ rspamc_symbols_output(FILE *out, ucl_object_t *obj) const ucl_object_t *cmesg; while ((cmesg = ucl_object_iterate (elt, &mit, true)) != nullptr) { - fmt::print(out, "Message - {}: {}\n", - ucl_object_key(cmesg), ucl_object_tostring(cmesg)); + if (ucl_object_type(cmesg) == UCL_STRING) { + fmt::print(out, "Message - {}: {}\n", + ucl_object_key(cmesg), ucl_object_tostring(cmesg)); + } else { + unsigned char *rendered_message; + rendered_message = ucl_object_emit(cmesg, UCL_EMIT_JSON_COMPACT); + fmt::print(out, "Message - {}: {:.60}\n", + ucl_object_key(cmesg), rendered_message); + free(rendered_message); + } } }