aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-08-10 23:55:31 +0800
committerLiana Husikyan <liana@ethdev.com>2015-08-10 23:55:31 +0800
commit8b433edc4e0b163b66f6c743bfcfea56a2e81be6 (patch)
tree51e14aa4da30c009c263c25f154f1aea22aee9ed
parent090e581fe85eb609324284b07dbe316f22d14612 (diff)
downloaddexon-solidity-8b433edc4e0b163b66f6c743bfcfea56a2e81be6.tar.gz
dexon-solidity-8b433edc4e0b163b66f6c743bfcfea56a2e81be6.tar.zst
dexon-solidity-8b433edc4e0b163b66f6c743bfcfea56a2e81be6.zip
added checks to prevent the self assignment
-rw-r--r--SourceLocation.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/SourceLocation.h b/SourceLocation.h
index 35e3c031..b8b57b60 100644
--- a/SourceLocation.h
+++ b/SourceLocation.h
@@ -41,8 +41,21 @@ struct SourceLocation
SourceLocation(): start(-1), end(-1) { }
SourceLocation(SourceLocation const& _other):
- start(_other.start), end(_other.end), sourceName(_other.sourceName) {}
- SourceLocation& operator=(SourceLocation const& _other) { start = _other.start; end = _other.end; sourceName = _other.sourceName; return *this;}
+ start(_other.start),
+ end(_other.end),
+ sourceName(_other.sourceName)
+ {}
+
+ SourceLocation& operator=(SourceLocation const& _other)
+ {
+ if (&_other == this)
+ return *this;
+
+ start = _other.start;
+ end = _other.end;
+ sourceName = _other.sourceName;
+ return *this;
+ }
bool operator==(SourceLocation const& _other) const { return start == _other.start && end == _other.end;}
bool operator!=(SourceLocation const& _other) const { return !operator==(_other); }