The "dlg" variable is not deleted.  Even better solution than deleting it would be not to use "dlg" as a pointer, so it will be deleted automatically at the end of the function.