added resource leak check and heap corruption check