mirror of
https://github.com/SOCI/soci.git
synced 2026-05-02 00:59:25 -05:00
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: Mateusz Loskot <mateusz@loskot.net>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user