commit 43c8a6d: [Minor] rspamc: fix crash on non-string element in `messages`
Andrew Lewis
nerf at judo.za.org
Fri Jul 15 11:49:03 UTC 2022
Author: Andrew Lewis
Date: 2022-07-15 13:26:10 +0200
URL: https://github.com/rspamd/rspamd/commit/43c8a6d8fe2f1c7abcdf86b30914fb60351254f2 (refs/pull/4214/head)
[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);
+ }
}
}
More information about the Commits
mailing list