[ORC] Check for underflow on SymbolStringPtr ref-counts.

This commit is contained in:
Lang Hames 2021-05-21 21:10:56 -07:00
parent 20634ece15
commit 4272fca2db
1 changed files with 9 additions and 3 deletions

View File

@ -62,8 +62,10 @@ public:
}
SymbolStringPtr& operator=(const SymbolStringPtr &Other) {
if (isRealPoolEntry(S))
if (isRealPoolEntry(S)) {
assert(S->getValue() && "Releasing SymbolStringPtr with zero ref count");
--S->getValue();
}
S = Other.S;
if (isRealPoolEntry(S))
++S->getValue();
@ -75,16 +77,20 @@ public:
}
SymbolStringPtr& operator=(SymbolStringPtr &&Other) {
if (isRealPoolEntry(S))
if (isRealPoolEntry(S)) {
assert(S->getValue() && "Releasing SymbolStringPtr with zero ref count");
--S->getValue();
}
S = nullptr;
std::swap(S, Other.S);
return *this;
}
~SymbolStringPtr() {
if (isRealPoolEntry(S))
if (isRealPoolEntry(S)) {
assert(S->getValue() && "Releasing SymbolStringPtr with zero ref count");
--S->getValue();
}
}
explicit operator bool() const { return S; }