You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/03/18 21:10:34 UTC
[trafficserver] branch 8.1.x updated: Don't assign if this and
other are the same object
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 8.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/8.1.x by this push:
new e6eadea Don't assign if this and other are the same object
e6eadea is described below
commit e6eadea8bb48a980b029664c27c662465567bcee
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Wed Apr 24 15:07:37 2019 +0800
Don't assign if this and other are the same object
(cherry picked from commit fde18999612520f71c6ee7742602d3f5e327cd07)
---
src/tscore/ink_uuid.cc | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/tscore/ink_uuid.cc b/src/tscore/ink_uuid.cc
index 92266cd..5f0eb3b 100644
--- a/src/tscore/ink_uuid.cc
+++ b/src/tscore/ink_uuid.cc
@@ -54,9 +54,11 @@ ATSUuid::initialize(TSUuidVersion v)
ATSUuid &
ATSUuid::operator=(const ATSUuid other)
{
- memcpy(_uuid.data, other._uuid.data, sizeof(_uuid.data));
- memcpy(_string, other._string, sizeof(_string));
- _version = other._version;
+ if (this != &other) { // Self assignment guard
+ memcpy(_uuid.data, other._uuid.data, sizeof(_uuid.data));
+ memcpy(_string, other._string, sizeof(_string));
+ _version = other._version;
+ }
return *this;
}