From: Vsevolod Stakhov Date: Thu, 10 Dec 2015 18:39:53 +0000 (+0000) Subject: Fix NULL strings, eh X-Git-Tag: 1.1.0~333 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2a5b7be24240377c4b1c1eba701b9ca2fd17c2ab;p=rspamd.git Fix NULL strings, eh --- diff --git a/src/libutil/printf.c b/src/libutil/printf.c index a6099f83f..11c464be8 100644 --- a/src/libutil/printf.c +++ b/src/libutil/printf.c @@ -482,13 +482,14 @@ rspamd_vprintf_common (rspamd_printf_append_func func, case 'V': v = va_arg (args, rspamd_fstring_t *); - slen = v->len; - - if (G_UNLIKELY (width != 0)) { - slen = MIN (v->len, width); - } if (v) { + slen = v->len; + + if (G_UNLIKELY (width != 0)) { + slen = MIN (v->len, width); + } + RSPAMD_PRINTF_APPEND (v->str, slen); } else { @@ -499,13 +500,13 @@ rspamd_vprintf_common (rspamd_printf_append_func func, case 'T': tok = va_arg (args, rspamd_ftok_t *); - slen = tok->len; - - if (G_UNLIKELY (width != 0)) { - slen = MIN (tok->len, width); - } if (tok) { + slen = tok->len; + + if (G_UNLIKELY (width != 0)) { + slen = MIN (tok->len, width); + } RSPAMD_PRINTF_APPEND (tok->begin, slen); } else { @@ -515,12 +516,14 @@ rspamd_vprintf_common (rspamd_printf_append_func func, case 'v': gs = va_arg (args, GString *); - slen = gs->len; - if (G_UNLIKELY (width != 0)) { - slen = MIN (gs->len, width); - } if (gs) { + slen = gs->len; + + if (G_UNLIKELY (width != 0)) { + slen = MIN (gs->len, width); + } + RSPAMD_PRINTF_APPEND (gs->str, slen); } else {