diff --git a/pgadmin/ctl/ctlSQLBox.cpp b/pgadmin/ctl/ctlSQLBox.cpp index 5c87173..98b1e4a 100644 --- a/pgadmin/ctl/ctlSQLBox.cpp +++ b/pgadmin/ctl/ctlSQLBox.cpp @@ -711,6 +711,12 @@ char *pg_query_to_single_ordered_string(char *query, void *dbptr) res->MoveNext(); } + //resolve memory leak + if(res) + { + delete res; + res = NULL; + } ret.Trim(); // Trims both space and tab, but we want to keep the space! if (ret.Length() > 0) diff --git a/pgadmin/dd/ddmodel/ddDBReverseEnginering.cpp b/pgadmin/dd/ddmodel/ddDBReverseEnginering.cpp index d3f4fc4..f3bef46 100644 --- a/pgadmin/dd/ddmodel/ddDBReverseEnginering.cpp +++ b/pgadmin/dd/ddmodel/ddDBReverseEnginering.cpp @@ -322,6 +322,11 @@ ddStubTable *ddImportDBUtils::getTable(pgConn *connection, wxString tableName, O } setUniqueConstraints(connection, table); setPkName(connection, table); + if(inhtables) + { + delete inhtables; + inhtables = NULL; + } return table; } @@ -658,6 +663,7 @@ void ddImportDBUtils::getAllRelationships(pgConn *connection, stubTablesHashMap { error = true; wxMessageBox(_("Error detecting kind of foreign key source: from Pk or from Uk"), _("Error importing relationship"), wxICON_ERROR | wxOK); + delete foreignKeys; return; } } @@ -671,6 +677,7 @@ void ddImportDBUtils::getAllRelationships(pgConn *connection, stubTablesHashMap if(fkFromPk == false && ukIndex < 0) { wxMessageBox(_("Error detecting kind of foreign key source: from Pk or from Uk"), _("Error importing relationship"), wxICON_ERROR | wxOK); + delete foreignKeys; return; } @@ -777,6 +784,7 @@ void ddImportDBUtils::getAllRelationships(pgConn *connection, stubTablesHashMap else { wxMessageBox(_("Error detecting kind of foreign key: null or not null"), _("Error importing relationship"), wxICON_ERROR | wxOK); + delete foreignKeys; return; } @@ -1137,6 +1145,7 @@ bool ddImportDBUtils::isModelSameDbFk(pgConn *connection, OID destTableOid, wxSt { error = true; wxMessageBox(_("Error detecting kind of foreign key source: from Pk or from Uk"), _("Error importing relationship"), wxICON_ERROR | wxOK); + delete foreignKeys; return false; } } @@ -1150,6 +1159,7 @@ bool ddImportDBUtils::isModelSameDbFk(pgConn *connection, OID destTableOid, wxSt if(fkFromPk == false && ukIndex < 0) { wxMessageBox(_("Error detecting kind of foreign key source: from Pk or from Uk"), _("Error importing relationship"), wxICON_ERROR | wxOK); + delete foreignKeys; return false; } @@ -1250,6 +1260,7 @@ bool ddImportDBUtils::isModelSameDbFk(pgConn *connection, OID destTableOid, wxSt else { wxMessageBox(_("Error detecting kind of foreign key: null or not null"), _("Error importing relationship"), wxICON_ERROR | wxOK); + delete foreignKeys; return false; } delete sourceStubTable; diff --git a/pgadmin/debugger/debugger.cpp b/pgadmin/debugger/debugger.cpp index 29f8621..ed67a43 100644 --- a/pgadmin/debugger/debugger.cpp +++ b/pgadmin/debugger/debugger.cpp @@ -49,12 +49,14 @@ wxWindow *debuggerFactory::StartDialog(frmMain *form, pgObject *obj) { form->Refresh(obj); } + delete res; return (wxWindow *)NULL; } if (res->GetVal(wxT("proname")).Contains(wxT(":"))) { wxLogError(_("Functions with a colon in the name cannot be debugged.")); + delete res; return (wxWindow *)NULL; } try @@ -66,7 +68,7 @@ wxWindow *debuggerFactory::StartDialog(frmMain *form, pgObject *obj) // just ignore this errors, we already logged them in native messages to // the end-user } - + delete res; return (wxWindow *)NULL; } @@ -159,6 +161,7 @@ wxWindow *breakpointFactory::StartDialog(frmMain *form, pgObject *obj) if (res->GetVal(wxT("proname")).Contains(wxT(":"))) { wxLogError(_("Functions with a colon in the name cannot be debugged.")); + delete res; return (wxWindow *)NULL; } @@ -174,6 +177,7 @@ wxWindow *breakpointFactory::StartDialog(frmMain *form, pgObject *obj) browser->DeleteChildren(coll->GetId()); coll->ShowTreeDetail(browser); } + delete res; return (wxWindow *)NULL; } @@ -187,6 +191,7 @@ wxWindow *breakpointFactory::StartDialog(frmMain *form, pgObject *obj) // the end-user } + delete res; return (wxWindow *)NULL; } diff --git a/pgadmin/dlg/dlgProperty.cpp b/pgadmin/dlg/dlgProperty.cpp index 74d36d5..00cb9f1 100644 --- a/pgadmin/dlg/dlgProperty.cpp +++ b/pgadmin/dlg/dlgProperty.cpp @@ -566,7 +566,10 @@ void dlgProperty::FillCombobox(const wxString &query, ctlComboBoxFix *cb1, ctlCo cb2->Append(set->GetVal(0)); set->MoveNext(); } + //resolve memory leak occurred while filling the combo Box in table property dialog + delete set; } + } @@ -1989,6 +1992,8 @@ void dlgDefaultSecurityProperty::AddUsers(ctlComboBox *combobox) set->MoveNext(); } + //resolves memory leak occurred while filling owner combo box in database property dialog + delete set; } } } diff --git a/pgadmin/dlg/dlgSelectDatabase.cpp b/pgadmin/dlg/dlgSelectDatabase.cpp index a13b484..a423bcd 100644 --- a/pgadmin/dlg/dlgSelectDatabase.cpp +++ b/pgadmin/dlg/dlgSelectDatabase.cpp @@ -111,6 +111,7 @@ void dlgSelectDatabase::Initialize() res->MoveNext(); } + delete res; } } } @@ -168,6 +169,7 @@ void dlgSelectDatabase::OnSelActivate(wxTreeEvent &ev) res->MoveNext(); } } + delete res; } tcServers->Expand(selID); } diff --git a/pgadmin/frm/frmEditGrid.cpp b/pgadmin/frm/frmEditGrid.cpp index 162904c..08f7b96 100644 --- a/pgadmin/frm/frmEditGrid.cpp +++ b/pgadmin/frm/frmEditGrid.cpp @@ -2305,6 +2305,8 @@ sqlTable::sqlTable(pgConn *conn, pgQueryThread *_thread, const wxString &tabName } allColsSet->MoveNext(); } + //removes memory leak + delete allColsSet; } pgSet *colSet = connection->ExecuteSet( diff --git a/pgadmin/include/utils/sysSettings.h b/pgadmin/include/utils/sysSettings.h index f3f9a47..609474e 100644 --- a/pgadmin/include/utils/sysSettings.h +++ b/pgadmin/include/utils/sysSettings.h @@ -24,7 +24,7 @@ class sysSettings : private wxConfig { public: sysSettings(const wxString &name); - + ~sysSettings(); // Display options bool GetDisplayOption(const wxString &objtype, bool GetDefault = false); void SetDisplayOption(const wxString &objtype, bool display); diff --git a/pgadmin/schema/gpExtTable.cpp b/pgadmin/schema/gpExtTable.cpp index 1947580..7508032 100644 --- a/pgadmin/schema/gpExtTable.cpp +++ b/pgadmin/schema/gpExtTable.cpp @@ -164,6 +164,7 @@ wxString gpExtTable::GetSql(ctlTree *browser) wxString errtblname = extTable->GetVal(6); wxString extencoding = extTable->GetVal(7); + delete extTable; if ((command.Length() > 0) || (locations.Mid(1, 4) == wxT("http"))) diff --git a/pgadmin/schema/pgAggregate.cpp b/pgadmin/schema/pgAggregate.cpp index c0b94a6..afffdc0 100644 --- a/pgadmin/schema/pgAggregate.cpp +++ b/pgadmin/schema/pgAggregate.cpp @@ -236,7 +236,8 @@ pgObject *pgAggregateFactory::CreateObjects(pgCollection *collection, ctlTree *b map[types->GetVal(wxT("oid"))] = types->GetVal(wxT("typname")); types->MoveNext(); } - + //resolve memory leak occurred while creating the pgAggregate object + delete types; // Build the query to get all objects wxString sql = wxT("SELECT aggfnoid::oid, proname AS aggname, pg_get_userbyid(proowner) AS aggowner, aggtransfn,\n") diff --git a/pgadmin/schema/pgIndex.cpp b/pgadmin/schema/pgIndex.cpp index 091db5d..8bb038f 100644 --- a/pgadmin/schema/pgIndex.cpp +++ b/pgadmin/schema/pgIndex.cpp @@ -298,6 +298,10 @@ void pgIndexBase::ReadColumnDetails() columns += coldef; quotedColumns += coldef; columnList.Add(coldef); + + //resolve memory leak occurred while expanding the index node in object browser + delete res; + res = NULL; } } else diff --git a/pgadmin/schema/pgTrigger.cpp b/pgadmin/schema/pgTrigger.cpp index cea0cad..d636239 100644 --- a/pgadmin/schema/pgTrigger.cpp +++ b/pgadmin/schema/pgTrigger.cpp @@ -305,6 +305,7 @@ void pgTrigger::ReadColumnDetails() i++; res->MoveNext(); } + delete res; } else { diff --git a/pgadmin/schema/pgType.cpp b/pgadmin/schema/pgType.cpp index 73bc216..d24a577 100644 --- a/pgadmin/schema/pgType.cpp +++ b/pgadmin/schema/pgType.cpp @@ -312,6 +312,7 @@ void pgType::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *proper if (set->GetVal(wxT("rngsubdiff")) != wxT("-")) iSetSubtypeDiff(set->GetVal(wxT("rngsubdiff"))); } + delete set; } } diff --git a/pgadmin/utils/registry.cpp b/pgadmin/utils/registry.cpp index 9eca740..6d83406 100644 --- a/pgadmin/utils/registry.cpp +++ b/pgadmin/utils/registry.cpp @@ -252,6 +252,8 @@ bool pgRegKey::QueryValue(const wxString &strVal, wxString &sVal) const } else sVal = pBuf; + + free(pBuf); return true; } return false; diff --git a/pgadmin/utils/sysSettings.cpp b/pgadmin/utils/sysSettings.cpp index decb6c4..30c163f 100644 --- a/pgadmin/utils/sysSettings.cpp +++ b/pgadmin/utils/sysSettings.cpp @@ -60,6 +60,16 @@ sysSettings::sysSettings(const wxString &name) : wxConfig(name) } } +sysSettings::~sysSettings() +{ + //removing defaultSetting at application closure to resolve the memory leak. + if(defaultSettings) + { + delete defaultSettings; + defaultSettings = NULL; + } +} + bool sysSettings::GetDisplayOption(const wxString &objtype, bool GetDefault) { bool retval, def = true;