diff --git a/cunit/util.testc b/cunit/util.testc index 9e3d6b41e7..6dbaa979e1 100644 --- a/cunit/util.testc +++ b/cunit/util.testc @@ -93,6 +93,7 @@ static void test_xsyslog_ev_escape_value(void) "\r", "\"\\r\"", "\r\n", "\"\\r\\n\"", "-12.345e67", "-12.345e67", + "", "\"\"", NULL, }; diff --git a/lib/util.c b/lib/util.c index 48456afd10..3f523b6603 100644 --- a/lib/util.c +++ b/lib/util.c @@ -2448,6 +2448,7 @@ static const char *xsyslog_ev_escape_value(struct buf *val) const char *p; escaped_len = orig_len = buf_len(val); + if (orig_len == 0) { return "\"\""; } // Make sure the empty string is visible for (p = buf_cstring(val); *p; p++) { switch (*p) {