Fix overflow issue in epee:misc_utils::rolling_median_t and median(), with unit test

This commit is contained in:
koe 2020-07-21 02:00:27 -05:00
parent 5d850dde99
commit 85efc88c1e
3 changed files with 23 additions and 2 deletions

View file

@ -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;
}