Fix errors detected by valgrind

I tried running chronyd in valgrind and the result was that there are four
places where memory is not initialized. A patch fixing the errors is in the
attachment.
This commit is contained in:
Miroslav Lichvar
2008-11-05 23:48:58 +00:00
committed by Richard P. Curnow
parent bc0aaa9217
commit 8336f14680
3 changed files with 12 additions and 3 deletions

View File

@@ -721,8 +721,12 @@ SST_PredictOffset(SST_Stats inst, struct timeval *when)
if (inst->n_samples < 3) {
/* We don't have any useful statistics, and presumably the poll
interval is minimal. We can't do any useful prediction other
than use the latest sample */
return inst->offsets[inst->n_samples - 1];
than use the latest sample or zero if we don't have any samples */
if (inst->n_samples > 0) {
return inst->offsets[inst->n_samples - 1];
} else {
return 0.0;
}
} else {
UTI_DiffTimevalsToDouble(&elapsed, when, &inst->offset_time);
return inst->estimated_offset + elapsed * inst->estimated_frequency;