(svn r20731) -Fix (r20739): SmallVector did not have an assignment operator, causing invalid memory reads / double free

This commit is contained in:
yexo
2010-09-03 23:04:02 +00:00
parent 9a0033cbf6
commit 0decc3e094
2 changed files with 10 additions and 2 deletions

View File

@@ -36,12 +36,20 @@ protected:
public:
SmallVector() : data(NULL), items(0), capacity(0) { }
template<uint X>
template <uint X>
SmallVector(const SmallVector<T, X> &other) : data(NULL), items(0), capacity(0)
{
MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
}
template <uint X>
SmallVector &operator=(const SmallVector<T, X> &other)
{
this->Reset();
MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
return *this;
}
~SmallVector()
{
free(this->data);