Commit 1f0c5741 authored by Alex Ott's avatar Alex Ott Committed by Mateusz Loskot

correctly handle negative values

sometimes, get_number_of_rows can return negative value, and this could lead to crash when
trying to resize vector
Signed-off-by: 's avatarMateusz Loskot <mateusz@loskot.net>
parent 64358c85
......@@ -495,16 +495,20 @@ bool statement_impl::resize_intos(std::size_t upperBound)
// this function does not need to take into account the intosForRow_
// elements, since they are never used for bulk operations
std::size_t rows = backEnd_->get_number_of_rows();
if (upperBound != 0 && upperBound < rows)
int rows = backEnd_->get_number_of_rows();
if (rows < 0)
{
rows = 0;
}
if (upperBound != 0 && upperBound < (std::size_t)rows)
{
rows = upperBound;
rows = (int)upperBound;
}
std::size_t const isize = intos_.size();
for (std::size_t i = 0; i != isize; ++i)
{
intos_[i]->resize(rows);
intos_[i]->resize((std::size_t)rows);
}
return rows > 0 ? true : false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment