]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] rspamc: fix crash on non-string element in `messages` 4214/head
authorAndrew Lewis <nerf@judo.za.org>
Fri, 15 Jul 2022 11:26:10 +0000 (13:26 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Fri, 15 Jul 2022 11:26:10 +0000 (13:26 +0200)
src/client/rspamc.cxx

index 3615d3be58342850fbcf0c45638dc973560aad23..cb847bf5b597657b16f20e336647a6507f25a578 100644 (file)
@@ -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);
+                       }
                }
        }