消除CppCheck检测的两个漏洞

This commit is contained in:
fasiondog 2019-03-27 01:37:59 +08:00
parent 012aae0abb
commit 8b49ab0406
3 changed files with 6 additions and 6 deletions

View File

@ -131,7 +131,7 @@ void KDataBufferImp::_recoverForUpDay() {
}
KRecord record = day_list[day_pos];
int pre_day_pos = day_pos;
while (day_list[day_pos].datetime <= phase_end_date && day_pos < day_total) {
while (day_pos < day_total && day_list[day_pos].datetime <= phase_end_date) {
if (day_list[day_pos].lowPrice < record.lowPrice) {
record.lowPrice = day_list[day_pos].lowPrice;
} else if (day_list[day_pos].highPrice > record.highPrice) {

View File

@ -350,11 +350,9 @@ Indicator IndicatorImp::calculate() {
//Python中继承的实现会出现bad_weak_ptr错误通过此方式避免
result = clone();
}
return Indicator(result);
} else {
return Indicator();
}
return Indicator(result);
}
if (!m_need_calculate) {
@ -443,8 +441,10 @@ Indicator IndicatorImp::calculate() {
try {
result = shared_from_this();
} catch (...) {
//Python中继承的实现会出现bad_weak_ptr错误通过此方式避免
result = clone();
}
return Indicator(result);
}

View File

@ -1825,7 +1825,7 @@ PriceList TradeManager
return result;
size_t i = 0;
while (dates[i] < m_init_datetime && i < total) {
while (i < total && dates[i] < m_init_datetime) {
result[i] = 0;
i++;
}