GH #305: There are bugs in Buffer.h

This commit is contained in:
Alex Fabijanic 2014-04-30 22:41:05 -05:00
parent ba3a8b08c5
commit 68044fdae0
2 changed files with 9 additions and 5 deletions

View File

@ -60,6 +60,7 @@ Release 1.5.3 (2014-05-xx)
- added GH #313: MetaColumn additions for Data::ODBC and Data::SQLite
- fixed GH #346: Make Poco::Data::Date and Poco::Data::Time compare functions const.
- fixed GH #341: Compiling poco-1.5.2 for Cygwin
- fixed GH #305: There are bugs in Buffer.h
Release 1.5.2 (2013-09-16)
==========================

View File

@ -142,7 +142,7 @@ public:
{
T* ptr = new T[newCapacity];
if (preserveContent)
std::memcpy(ptr, _ptr, _used);
std::memcpy(ptr, _ptr, _used * sizeof(T));
delete [] _ptr;
_ptr = ptr;
@ -171,7 +171,10 @@ public:
{
T* ptr = new T[newCapacity];
if (preserveContent)
std::memcpy(ptr, _ptr, _used < newCapacity ? _used : newCapacity);
{
std::size_t newSz = _used < newCapacity ? _used : newCapacity;
std::memcpy(ptr, _ptr, newSz * sizeof(T));
}
delete [] _ptr;
_ptr = ptr;
@ -187,7 +190,7 @@ public:
{
if (0 == sz) return;
if (sz > _capacity) resize(sz, false);
std::memcpy(_ptr, buf, sz);
std::memcpy(_ptr, buf, sz * sizeof(T));
_used = sz;
}
@ -196,7 +199,7 @@ public:
{
if (0 == sz) return;
resize(_used + sz, true);
std::memcpy(_ptr + _used - sz, buf, sz);
std::memcpy(_ptr + _used - sz, buf, sz * sizeof(T));
}
void append(T val)
@ -241,7 +244,7 @@ public:
{
if (_used == other._used)
{
if (std::memcmp(_ptr, other._ptr, _used) == 0)
if (std::memcmp(_ptr, other._ptr, _used * sizeof(T)) == 0)
{
return true;
}