diff -Naurp a/lib/util/debug.c b/lib/util/debug.c --- a/lib/util/debug.c 2017-01-11 08:55:14.000000000 +0100 +++ b/lib/util/debug.c 2017-04-15 18:39:21.939188030 +0200 @@ -397,7 +397,7 @@ static void debug_backends_log(const cha * a buffer without the newline character. */ len = MIN(strlen(msg), FORMAT_BUFR_SIZE - 1); - if (msg[len - 1] == '\n') { + if ((len > 0) && (msg[len - 1] == '\n')) { len--; }