]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Fix bug in distribution_percentile function
authorBarbara Kaczorowska <bkjg@google.com>
Tue, 18 Aug 2020 23:22:22 +0000 (23:22 +0000)
committerBarbara Kaczorowska <bkjg@google.com>
Wed, 19 Aug 2020 07:43:20 +0000 (07:43 +0000)
This commit will add fix to the distribution_percentile function.
Before this commit, distribution_percentile function didn't check
if it received null pointer as an argument and didn't handle this
case and in result it had seg fault. Now this bug is fixed.

src/daemon/distribution.c

index a0731423ef5d07286079c011e011560d791858b9..52201b7e791781ec678d716c541d92cb8ec6a2b8 100644 (file)
@@ -242,7 +242,7 @@ static double tree_get_counter(distribution_t *d, size_t node_index,
 }
 
 double distribution_percentile(distribution_t *dist, double percent) {
-  if (percent <= 0 || percent > 100) {
+  if (percent <= 0 || percent > 100 || dist == NULL) {
     errno = EINVAL;
     return NAN;
   }