]> source.dussan.org Git - rspamd.git/commitdiff
Fix NULL strings, eh
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Dec 2015 18:39:53 +0000 (18:39 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 10 Dec 2015 18:39:53 +0000 (18:39 +0000)
src/libutil/printf.c

index a6099f83fbb04572511ea92c98acfa2769ac2d4c..11c464be86450e3739f564153a33384565a3f479 100644 (file)
@@ -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 {