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;
}
Resource leak in wxsqlite3.cpp
Moderator: Renato
-
- Super User
- Posts: 142
- Joined: Mon Aug 03, 2009 7:35 am
- Are you a spam bot?: No
-
- Super User
- Posts: 142
- Joined: Mon Aug 03, 2009 7:35 am
- Are you a spam bot?: No
Re: Resource leak in wxsqlite3.cpp
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.
I think it would be better to update sources of wxSQLite3 in our project.
-
- Super User
- Posts: 142
- Joined: Mon Aug 03, 2009 7:35 am
- Are you a spam bot?: No
Re: Resource leak in wxsqlite3.cpp
This bug still presents in the latest version
I have registered this bug on bugtracker of project.
I have registered this bug on bugtracker of project.
-
- Super User
- Posts: 142
- Joined: Mon Aug 03, 2009 7:35 am
- Are you a spam bot?: No
Re: Resource leak in wxsqlite3.cpp
The bug has fixed by author of wxSQLite3.
http://sourceforge.net/tracker/?func=de ... tid=462816
http://sourceforge.net/tracker/?func=de ... tid=462816
-
- Site Admin
- Posts: 99
- Joined: Sun Nov 30, 2008 8:06 pm
Re: Resource leak in wxsqlite3.cpp
Good Find Vadim.
Do you have files you can supply to replace the ones in the sources?
Do you have files you can supply to replace the ones in the sources?
-
- Super User
- Posts: 142
- Joined: Mon Aug 03, 2009 7:35 am
- Are you a spam bot?: No
Re: Resource leak in wxsqlite3.cpp
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?
In mmex I see include\wx and include\wxsqlite3_secure. Which of them should I update? Or update both?
-
- Super User
- Posts: 142
- Joined: Mon Aug 03, 2009 7:35 am
- Are you a spam bot?: No
Re: Resource leak in wxsqlite3.cpp
wxsqlite3 sources upgraded to the latest version (currently 1.9.5).
Committed revision 412.
Committed revision 412.