mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-27 08:46:17 +01:00
Fixed bug: Pointers to vector internas were given away and became invalid because of resizing the vector
This commit is contained in:
parent
72b5b7acae
commit
6149beb920
@ -251,6 +251,8 @@ public:
|
||||
/// Update linked times
|
||||
|
||||
private:
|
||||
Binder(const Binder&);
|
||||
/// Don't copy the binder
|
||||
|
||||
virtual void bind(std::size_t, const char* const&, Direction)
|
||||
/// Binds a const char ptr.
|
||||
@ -265,7 +267,7 @@ private:
|
||||
private:
|
||||
|
||||
std::vector<MYSQL_BIND> _bindArray;
|
||||
std::vector<MYSQL_TIME> _dates;
|
||||
std::vector<MYSQL_TIME*> _dates;
|
||||
};
|
||||
|
||||
|
||||
|
@ -49,6 +49,11 @@ Binder::Binder()
|
||||
|
||||
Binder::~Binder()
|
||||
{
|
||||
for (std::vector<MYSQL_TIME*>::iterator it = _dates.begin(); it != _dates.end(); ++it)
|
||||
{
|
||||
delete *it;
|
||||
*it = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -188,9 +193,9 @@ void Binder::bind(std::size_t pos, const DateTime& val, Direction dir)
|
||||
|
||||
mt.time_type = MYSQL_TIMESTAMP_DATETIME;
|
||||
|
||||
_dates.push_back(mt);
|
||||
_dates.push_back(new MYSQL_TIME(mt));
|
||||
|
||||
realBind(pos, MYSQL_TYPE_DATETIME, &_dates.back(), sizeof(mt));
|
||||
realBind(pos, MYSQL_TYPE_DATETIME, _dates.back(), sizeof(MYSQL_TIME));
|
||||
}
|
||||
|
||||
|
||||
@ -203,9 +208,9 @@ void Binder::bind(std::size_t pos, const Date& val, Direction dir)
|
||||
mt.month = val.month();
|
||||
mt.day = val.day();
|
||||
|
||||
_dates.push_back(mt);
|
||||
_dates.push_back(new MYSQL_TIME(mt));
|
||||
|
||||
realBind(pos, MYSQL_TYPE_DATE, &_dates.back(), sizeof(mt));
|
||||
realBind(pos, MYSQL_TYPE_DATE, _dates.back(), sizeof(MYSQL_TIME));
|
||||
}
|
||||
|
||||
|
||||
@ -220,9 +225,9 @@ void Binder::bind(std::size_t pos, const Time& val, Direction dir)
|
||||
|
||||
mt.time_type = MYSQL_TIMESTAMP_TIME;
|
||||
|
||||
_dates.push_back(mt);
|
||||
_dates.push_back(new MYSQL_TIME(mt));
|
||||
|
||||
realBind(pos, MYSQL_TYPE_TIME, &_dates.back(), sizeof(mt));
|
||||
realBind(pos, MYSQL_TYPE_TIME, _dates.back(), sizeof(MYSQL_TIME));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user