Fix crash when reloading history with zero samples

This commit is contained in:
Miroslav Lichvar 2010-08-25 18:31:28 +02:00
parent 3a222336d7
commit 061d497df0

View file

@ -172,6 +172,7 @@ SST_CreateInstance(unsigned long refid, IPAddr *addr)
inst->n_samples = 0; inst->n_samples = 0;
inst->runs_samples = 0; inst->runs_samples = 0;
inst->last_sample = 0; inst->last_sample = 0;
inst->best_single_sample = 0;
inst->estimated_frequency = 0; inst->estimated_frequency = 0;
inst->skew = 2000.0e-6; inst->skew = 2000.0e-6;
inst->skew_dirn = SST_Skew_Nochange; inst->skew_dirn = SST_Skew_Nochange;
@ -293,6 +294,9 @@ find_best_sample_index(SST_Stats inst, double *times_back)
double elapsed; double elapsed;
int i, j, best_index; int i, j, best_index;
if (!inst->n_samples)
return;
best_index = -1; best_index = -1;
best_root_distance = DBL_MAX; best_root_distance = DBL_MAX;