src/gui/streaminfo2.cpp: fix possible integer overflow if fe driver reports very high values. The fix is to check for overflow and if so just return max_y.

Origin commit data
------------------
Commit: 60a53d9eb5
Author: [CST] Bas <bas@coolstreamtech.com>
Date: 2014-06-12 (Thu, 12 Jun 2014)
This commit is contained in:
[CST] Bas
2014-06-12 08:18:47 +02:00
committed by [CST] Focus
parent 74f731f23f
commit b819933f88

View File

@@ -369,13 +369,20 @@ void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s)
// -- calc y from max_range and max_y
int CStreamInfo2::y_signal_fe (unsigned long value, unsigned long max_value, int max_y)
{
long l;
unsigned long long m;
unsigned long l;
if (!max_value)
max_value = 1;
l = ((long) max_y * (long) value) / (long) max_value;
if (l > max_y)
// we use a 64 bits int here to detect integer overflow
// and if it overflows, just return max_y
m = (unsigned long long)value * max_y;
if (m > 0xffffffff)
return max_y;
l = m / max_value;
if (l > (unsigned long)max_y)
l = max_y;
return (int) l;