From f611102db35ed51cf0a572661b8d69c8bb7da8f6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 13 Mar 2019 12:38:46 +0100 Subject: [PATCH] PVS: V794 The assignment operator should be protected from the case of 'this == ...' --- src/Mod/Path/App/Path.cpp | 3 +++ src/Mod/Path/libarea/kurve/kurve.cpp | 5 +++++ src/Mod/Robot/App/Trajectory.cpp | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/Mod/Path/App/Path.cpp b/src/Mod/Path/App/Path.cpp index 4e0fb05b8d..7b80f6af51 100644 --- a/src/Mod/Path/App/Path.cpp +++ b/src/Mod/Path/App/Path.cpp @@ -65,6 +65,9 @@ Toolpath::~Toolpath() Toolpath &Toolpath::operator=(const Toolpath& otherPath) { + if (this == &otherPath) + return *this; + clear(); vpcCommands.resize(otherPath.vpcCommands.size()); int i = 0; diff --git a/src/Mod/Path/libarea/kurve/kurve.cpp b/src/Mod/Path/libarea/kurve/kurve.cpp index 66cb3d413c..fc3f451775 100644 --- a/src/Mod/Path/libarea/kurve/kurve.cpp +++ b/src/Mod/Path/libarea/kurve/kurve.cpp @@ -34,6 +34,8 @@ namespace geoff_geometry { const SpanVertex& SpanVertex::operator= (const SpanVertex& spv ){ /// + if (this == &spv) + return *this; memcpy(x, spv.x, SPANSTORAGE * sizeof(double)); memcpy(y, spv.y, SPANSTORAGE * sizeof(double)); @@ -430,6 +432,9 @@ namespace geoff_geometry { } const Kurve& Kurve::operator=( const Kurve &k) { + if (this == &k) + return *this; + memcpy(e, k.e, 16 * sizeof(double)); m_unit = k.m_unit; m_mirrored = k.m_mirrored; diff --git a/src/Mod/Robot/App/Trajectory.cpp b/src/Mod/Robot/App/Trajectory.cpp index 61f4532ca2..c4f04e6a09 100644 --- a/src/Mod/Robot/App/Trajectory.cpp +++ b/src/Mod/Robot/App/Trajectory.cpp @@ -81,6 +81,9 @@ Trajectory::~Trajectory() Trajectory &Trajectory::operator=(const Trajectory& Trac) { + if (this == &Trac) + return *this; + for(std::vector::iterator it = vpcWaypoints.begin();it!=vpcWaypoints.end();++it) delete ( *it ); vpcWaypoints.clear();