Don't crash on NULL pointers being dealloc'd

* The error handling code will be OK if a NULL parameter was passed in
  but during cleanup it will go through tempdealloc, so we need to check
  that the pointer is actually valid.
This commit is contained in:
baldurk
2017-06-09 16:57:33 +01:00
parent 27ae30aaa3
commit 21836c240d
+5 -1
View File
@@ -978,7 +978,11 @@ struct pointer_unwrap<T, true>
static void tempset(U *&ptr, U *tempobj) { ptr = tempobj; }
static void tempalloc(U *&ptr, unsigned char *tempmem) { ptr = new(tempmem) U; }
static void tempdealloc(U *ptr) { ptr->~U(); }
static void tempdealloc(U *ptr)
{
if(ptr)
ptr->~U();
}
static U &indirect(U *ptr) { return *ptr; }
};
};