From 43c8a6d8fe2f1c7abcdf86b30914fb60351254f2 Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Fri, 15 Jul 2022 13:26:10 +0200 Subject: [PATCH] [Minor] rspamc: fix crash on non-string element in `messages` --- src/client/rspamc.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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); + } } } -- 2.39.5