Resource leak in wxsqlite3.cpp

Money Manager Ex Development related posts for both Android and Desktop

Moderator: Renato

Post Reply
Vadim
Super MMEX User
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Resource leak in wxsqlite3.cpp

Post by Vadim »

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;
}
Vadim
Super MMEX User
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: Resource leak in wxsqlite3.cpp

Post by Vadim »

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.
Vadim
Super MMEX User
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: Resource leak in wxsqlite3.cpp

Post by Vadim »

This bug still presents in the latest version :(
I have registered this bug on bugtracker of project.
Vadim
Super MMEX User
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: Resource leak in wxsqlite3.cpp

Post by Vadim »

The bug has fixed by author of wxSQLite3.
http://sourceforge.net/tracker/?func=de ... tid=462816
madhan
Site Admin
Posts: 99
Joined: Sun Nov 30, 2008 8:06 pm

Re: Resource leak in wxsqlite3.cpp

Post by madhan »

Good Find Vadim.

Do you have files you can supply to replace the ones in the sources?
Vadim
Super MMEX User
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: Resource leak in wxsqlite3.cpp

Post by Vadim »

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?
Vadim
Super MMEX User
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: Resource leak in wxsqlite3.cpp

Post by Vadim »

wxsqlite3 sources upgraded to the latest version (currently 1.9.5).
Committed revision 412.
Post Reply