From 2fb203e6efec1dbbe59184fb4927dd9b6f0a480f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 3 Jan 2002 17:18:38 +0000 Subject: [PATCH] fixed memory leak in wxHTTP git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13336 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 ++ include/wx/protocol/http.h | 3 +++ src/common/http.cpp | 16 ++++++++++------ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f37b98079c..d6cefad1e9 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -68,6 +68,7 @@ wxBase: - fixes to the command line parsing error and usage messages - modified wxFileName::CreateTempFileName() to open the file atomically (if possible) and, especially, not to leak the file descriptors under Unix +- memory leak in wxHTTP fixed (Dimitri) All (GUI): @@ -82,6 +83,7 @@ wxMSW: - fixed redraw problems in dynamically resized wxStaticText - fixed wxProgressDialog for ranges > 65535 - wxFontEnumerator now returns all fonts, not only TrueType ones +- wxTextCtrl with wxTE_RICH flag scrolls to the end when text is appended to it 2.3.2 ----- diff --git a/include/wx/protocol/http.h b/include/wx/protocol/http.h index 7b4f5db705..72080ba71d 100644 --- a/include/wx/protocol/http.h +++ b/include/wx/protocol/http.h @@ -50,6 +50,9 @@ protected: bool BuildRequest(const wxString& path, wxHTTP_Req req); void SendHeaders(); bool ParseHeaders(); + + // deletes the header value strings + void ClearHeaders(); }; #endif // wxUSE_PROTOCOL_HTTP diff --git a/src/common/http.cpp b/src/common/http.cpp index bda7c28d00..55b44ed76d 100644 --- a/src/common/http.cpp +++ b/src/common/http.cpp @@ -49,6 +49,13 @@ wxHTTP::wxHTTP() } wxHTTP::~wxHTTP() +{ + ClearHeaders(); + + delete m_addr; +} + +void wxHTTP::ClearHeaders() { // wxString isn't a wxObject wxNode *node = m_headers.First(); @@ -60,10 +67,7 @@ wxHTTP::~wxHTTP() node = node->Next(); } - if (m_addr) { - delete m_addr; - m_addr = NULL; - } + m_headers.Clear(); } wxString wxHTTP::GetContentType() @@ -79,7 +83,7 @@ void wxHTTP::SetProxyMode(bool on) void wxHTTP::SetHeader(const wxString& header, const wxString& h_data) { if (m_read) { - m_headers.Clear(); + ClearHeaders(); m_read = FALSE; } @@ -130,7 +134,7 @@ bool wxHTTP::ParseHeaders() wxString line; wxStringTokenizer tokenzr; - m_headers.Clear(); + ClearHeaders(); m_read = TRUE; #if defined(__VISAGECPP__) -- 2.45.2