diff options
author | koe <ukoe@protonmail.com> | 2020-07-21 02:00:27 -0500 |
---|---|---|
committer | koe <ukoe@protonmail.com> | 2020-07-23 03:36:05 -0500 |
commit | 85efc88c1edc7371ca5c8722c896fd64a258ddd2 (patch) | |
tree | 82603bf55a58a77a797193e81bac479f4a2adc6c /contrib/epee/include/rolling_median.h | |
parent | Merge pull request #6586 (diff) | |
download | monero-85efc88c1edc7371ca5c8722c896fd64a258ddd2.tar.xz |
Fix overflow issue in epee:misc_utils::rolling_median_t and median(), with unit test
Diffstat (limited to '')
-rw-r--r-- | contrib/epee/include/rolling_median.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/contrib/epee/include/rolling_median.h b/contrib/epee/include/rolling_median.h index 11275aa70..088a71d3e 100644 --- a/contrib/epee/include/rolling_median.h +++ b/contrib/epee/include/rolling_median.h @@ -34,6 +34,8 @@ #pragma once +#include "misc_language.h" + #include <stdlib.h> #include <stdint.h> @@ -226,7 +228,7 @@ public: Item v = data[heap[0]]; if (minCt < maxCt) { - v = (v + data[heap[-1]]) / 2; + v = get_mid<Item>(v, data[heap[-1]]); } return v; } |