Resource leak in wxsqlite3.cpp

Page 1 of 1
7 posts
Resource leak in wxsqlite3.cpp

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
Hi,
Class wxSQLite3Statement (wxsqlite3.cpp) has resource leak in its operator=().
The code does not release m_stmt before assigning new value to one.

wxSQLite3Statement& wxSQLite3Statement::operator=(const wxSQLite3Statement& statement)
{
m_db = statement.m_db;
m_stmt = statement.m_stmt; // RESOURCE LEAK, must be called sqlite3_finalize(m_stmt) first!!!
// Only one object can own prepared statement
const_cast<wxSQLite3Statement&>(statement).m_stmt = 0;
return *this;
}


Take a look at similar right code.

wxSQLite3ResultSet& wxSQLite3ResultSet::operator=(const wxSQLite3ResultSet& resultSet)
{
try
{
Finalize(); // free m_stmt if owns
}
catch (...)
{
}
m_stmt = resultSet.m_stmt;
// Only one object can own the statement
const_cast<wxSQLite3ResultSet&>(resultSet).m_stmt = 0;
m_eof = resultSet.m_eof;
m_first = resultSet.m_first;
m_cols = resultSet.m_cols;
m_ownStmt = resultSet.m_ownStmt;
return *this;
}
Re: Resource leak in wxsqlite3.cpp

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
The latest release of wxSQLite3 is 1.9.5, wxcode.sourceforge.net/components/wxsqlite3.
I think it would be better to update sources of wxSQLite3 in our project.
Re: Resource leak in wxsqlite3.cpp

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
This bug still presents in the latest version :(
I have registered this bug on bugtracker of project.
Re: Resource leak in wxsqlite3.cpp

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
The bug has fixed by author of wxSQLite3.
http://sourceforge.net/tracker/?func=de ... tid=462816
Re: Resource leak in wxsqlite3.cpp

madhan
Site Admin

Posts: 242
Joined: Sun Nov 30, 2008 2:06 pm
Good Find Vadim.

Do you have files you can supply to replace the ones in the sources?
Re: Resource leak in wxsqlite3.cpp

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
I have downloaded the latest version of wxsqlite3. Surely, I can update sources. But the distribution of wxsqlite3-1.9.5 contains wxsqlite3.h wxsqlite3def.h wxsqlite3dyn.h wxsqlite3opt.h.
In mmex I see include\wx and include\wxsqlite3_secure. Which of them should I update? Or update both?
Re: Resource leak in wxsqlite3.cpp

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
wxsqlite3 sources upgraded to the latest version (currently 1.9.5).
Committed revision 412.
Page 1 of 1
Who is online

Users browsing this forum: No registered users and 2 guests

cron