Fix bug in vector8 operator=

operator= would try to overwrite it self under some circumstances.
This was found with valgrind and using -O0. It works with -O2.
This commit is contained in:
Cary R 2009-10-02 19:22:53 -07:00 committed by Stephen Williams
parent 27f96bd6f3
commit 9ea6604439
1 changed files with 2 additions and 1 deletions

View File

@ -2442,7 +2442,8 @@ const vvp_vector8_t vvp_vector8_t::nil;
vvp_vector8_t& vvp_vector8_t::operator= (const vvp_vector8_t&that)
{
// Assign to self.
if (size_ > PTR_THRESH && that.size_ > PTR_THRESH && ptr_ == that.ptr_)
if (this == &that || (size_ > PTR_THRESH && that.size_ > PTR_THRESH &&
ptr_ == that.ptr_))
return *this;
if (size_ != that.size_) {