diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 4ea849e64f..d27e6e599a 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -1034,7 +1034,7 @@ cfg_print_duration(cfg_printer_t *pctx, const cfg_obj_t *obj) { char *str; const char *indicators = "YMWDHMS"; int count, i; - int durationlen[7]; + int durationlen[7] = { 0 }; isccfg_duration_t duration; /* * D ? The duration has a date part. @@ -1066,10 +1066,8 @@ cfg_print_duration(cfg_printer_t *pctx, const cfg_obj_t *obj) { } else { T = true; } - } else { - durationlen[i] = 0; + count += durationlen[i]; } - count += durationlen[i]; } /* * Special case for seconds which is not taken into account in the @@ -1107,7 +1105,7 @@ cfg_print_duration(cfg_printer_t *pctx, const cfg_obj_t *obj) { } /* Special case for seconds. */ if (duration.parts[6] > 0 || - (!D && !duration.parts[4] && !duration.parts[3])) { + (!D && !duration.parts[4] && !duration.parts[5])) { snprintf(str, durationlen[6] + 2, "%u%c", (uint32_t)duration.parts[6], indicators[6]); }