浏览代码

COMP: remove warning and check for assignment to itself in operator=

Bill Hoffman 17 年之前
父节点
当前提交
0143b83264
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      Source/kwsys/RegularExpression.cxx

+ 4 - 0
Source/kwsys/RegularExpression.cxx

@@ -77,6 +77,10 @@ RegularExpression::RegularExpression (const RegularExpression& rxp) {
 // operator= -- Copies the given regular expression.
 RegularExpression& RegularExpression::operator= (const RegularExpression& rxp)
 {
+  if(this == &rxp)
+    {
+    return *this;
+    }
   if ( !rxp.program )
     {
     this->program = 0;