prevent simple Any self-assignment

This commit is contained in:
Michael Davidsaver
2023-02-13 08:28:35 -08:00
parent e0a8572c2d
commit 4029f5ac3c
2 changed files with 24 additions and 2 deletions
+4 -1
View File
@@ -655,7 +655,10 @@ void Value::copyIn(const void *ptr, StoreType type)
// assigning variant union.
auto& val = store->as<Value>();
if(type==StoreType::Compound) {
val = *reinterpret_cast<const Value*>(ptr);
auto& newval = *reinterpret_cast<const Value*>(ptr);
if(store == newval.store)
throw std::logic_error("Any self-assignment would recurse. Not allowed.");
val = newval;
break;
} else {