Ftp连接正常时,CInternetException造成内存泄露
错误提示是这样的:
Detected memory leaks!
Dumping objects ->
inet.cpp(2746) : {667} client block at 0x003D7A00, subtype 0, 20 bytes long.
a CInternetException object at $003D7A00, 20 bytes long
inet.cpp(2746) : {521} client block at 0x003D79A8, subtype 0, 20 bytes long.
a CInternetException object at $003D79A8, 20 bytes long
inet.cpp(2746) : {375} client block at 0x003D78D8, subtype 0, 20 bytes long.
a CInternetException object at $003D78D8, 20 bytes long
Object dump complete.
The thread 0xC80 has exited with code 0 (0x0).
软件代码如下:
BOOL CFtp::ConnectServer(CString sFtpServerName, CString sFtpUser, CString sFtpPassword, CString& sError)
{
if(m_pFinder)
{
m_pFinder->Close();
delete m_pFinder;
m_pFinder = NULL;
}
if(m_pFtp)
{
m_pFtp->Close();
delete m_pFtp;
m_pFtp = NULL;
}
try
{
m_pFtp = m_Session.GetFtpConnection(sFtpServerName, sFtpUser, sFtpPassword);
}
catch(CInternetException *pex) //内存泄露
{
TCHAR szErr[1024];
pex->GetErrorMessage(szErr, 1024);
sError = szErr;
pex->Delete();
pex=NULL;
return FALSE;
}
m_pFinder = new CFtpFileFind(m_pFtp);
m_sFtpServerName = sFtpServerName;
m_sFtpUser = sFtpUser;
m_sFtpPassword = sFtpPassword;
return TRUE;
}
跟踪发现,当ftp连接正常后,CInternetException 对象也被构造出来了,造成内存泄露.不知道怎么会产生这个问题,请高手指点!