Don't use if (ptr) delete ptr; call delete ptr; directly, it contains the test for null ptr.
a5882a1a1c