]> source.dussan.org Git - rspamd.git/commitdiff
Fix double format output.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 16 Jan 2015 12:24:16 +0000 (12:24 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 16 Jan 2015 12:24:16 +0000 (12:24 +0000)
src/libutil/printf.c

index d43e38810d0185b3dda0070262421c7cc1a322eb..26fc174e8ddb273139c9247d19080c43e0d9ce2e 100644 (file)
@@ -411,8 +411,19 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
                                case '.':
                                        fmt++;
 
-                                       while (*fmt >= '0' && *fmt <= '9') {
-                                               frac_width = frac_width * 10 + *fmt++ - '0';
+                                       if (*fmt == '*') {
+                                               d = (gint)va_arg (args, gint);
+                                               if (G_UNLIKELY (d < 0)) {
+                                                       msg_err ("critical error: fraction width is less than 0");
+                                                       return 0;
+                                               }
+                                               frac_width = (guint)d;
+                                               fmt++;
+                                       }
+                                       else {
+                                               while (*fmt >= '0' && *fmt <= '9') {
+                                                       frac_width = frac_width * 10 + *fmt++ - '0';
+                                               }
                                        }
 
                                        break;