From: Miroslav Lichvar Date: Thu, 15 Feb 2018 16:10:45 +0000 (+0100) Subject: sourcestats: reset instance before loading dump file X-Git-Tag: 3.3-pre1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45f27f4f5e8c734be5179eea3a86afeb74bf9c6c;p=thirdparty%2Fchrony.git sourcestats: reset instance before loading dump file Don't rely on the caller to reset the instance and always reset it before loading data to make sure it can't get to an unexpected state. --- diff --git a/sourcestats.c b/sourcestats.c index 2aec02ca..9c1c4dec 100644 --- a/sourcestats.c +++ b/sourcestats.c @@ -884,7 +884,7 @@ SST_LoadFromFile(SST_Stats inst, FILE *in) char line[1024]; double weight; - assert(!inst->n_samples); + SST_ResetInstance(inst); if (fgets(line, sizeof(line), in) && sscanf(line, "%d", &inst->n_samples) == 1 && @@ -933,7 +933,6 @@ SST_LoadFromFile(SST_Stats inst, FILE *in) return 1; inst->last_sample = inst->n_samples - 1; - inst->runs_samples = 0; find_min_delay_sample(inst); SST_DoNewRegression(inst);