This delete isn't going to get reached - the exception will lift us straight out of the function, leaking memory and presumably file handles. I'd suggest using a boost::shared_ptr for out, and then whatever path we take out of the function, the delete will be done for us.