[syslog-ng] [PATCH 7/7] jsonparser: Only prepend a prefix if there is one

Gergely Nagy algernon at balabit.hu
Fri Sep 14 11:52:01 CEST 2012


In log_json_parser_process_single(), when parsing an object element,
only prepend a prefix if there is one, otherwise g_string_assign()
will complain on stderr with an assert, which is not something we'd
like.

Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 modules/json/jsonparser.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/json/jsonparser.c b/modules/json/jsonparser.c
index 21b605d..d3c2b66 100644
--- a/modules/json/jsonparser.c
+++ b/modules/json/jsonparser.c
@@ -99,7 +99,8 @@ log_json_parser_process_single (struct json_object *jso,
                        json_object_get_string (jso));
       break;
     case json_type_object:
-      g_string_assign (sb_string (key), prefix);
+      if (prefix)
+        g_string_assign (sb_string (key), prefix);
       g_string_append (sb_string (key), obj_key);
       g_string_append_c (sb_string (key), '.');
       log_json_parser_process_object (jso, sb_string (key)->str, msg);
-- 
1.7.10.4




More information about the syslog-ng mailing list