Commit e73f49ca authored by Damien L-G's avatar Damien L-G

Set internal pointer to null after calling free on the internal pointer in RAII's destructor

parent 1ea27a36
......@@ -25,7 +25,11 @@ public:
typename = std::enable_if_t<(sizeof...(Args) != 1)>>
RAII(Args &&... args)
: _p{AllocatorTraits<T>::allocate(std::forward<Args>(args)...)} {}
~RAII() { AllocatorTraits<T>::free(_p); }
~RAII() {
// GSL returns early if _p is null so don't bother checking
AllocatorTraits<T>::free(_p);
_p = nullptr;
}
RAII(RAII const &) = delete;
RAII &operator=(RAII &) = delete;
operator T *() { return _p; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment