From d2a900d187f7568b3ea18096388c20c633dc1923 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 2 Oct 2009 19:22:53 -0700 Subject: [PATCH] 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. (cherry picked from commit 9ea6604439f4e06d32c80bf187325233d2c487b6) --- vvp/vvp_net.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index cdf3cfe67..6fdc1f744 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -2308,7 +2308,8 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector4_t&that, 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_) {