Fixed a delete issue caught by AddressSanitizer