libexpr: Call destructor on exception_ptr
This uses `gc_cleanup` to call the exception_ptr destructor when the `Failed` is collected. I don't know exactly how bad it is to deallocate `std::exception_ptr` without destruction, but I guess it ranges from small leak to UB and crash.
This commit is contained in:
@@ -268,9 +268,22 @@ struct ValueBase
|
||||
Value * const * elems;
|
||||
};
|
||||
|
||||
struct Failed : gc
|
||||
/**
|
||||
Representation of an evaluation that previously failed.
|
||||
|
||||
`Value` references `Failed` by packed pointer, and its `new` is GC managed.
|
||||
|
||||
@see gc_cleanup std::exception_ptr
|
||||
*/
|
||||
class Failed : public gc_cleanup
|
||||
{
|
||||
public:
|
||||
std::exception_ptr ex;
|
||||
|
||||
Failed(std::exception_ptr && ex)
|
||||
: ex(ex)
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1075,7 +1088,7 @@ public:
|
||||
|
||||
inline void mkFailed() noexcept
|
||||
{
|
||||
setStorage(new Value::Failed{.ex = std::current_exception()});
|
||||
setStorage(new Value::Failed(std::current_exception()));
|
||||
}
|
||||
|
||||
bool isList() const noexcept
|
||||
|
||||
Reference in New Issue
Block a user