]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Fix crash when reloading history with zero samples
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 25 Aug 2010 16:31:28 +0000 (18:31 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 25 Aug 2010 16:32:40 +0000 (18:32 +0200)
sourcestats.c

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