From 02f697d0c050ee2e50db9e8646818cf19955d053 Mon Sep 17 00:00:00 2001 From: Ilya Sinitsyn Date: Tue, 13 Oct 2020 14:00:56 +0700 Subject: [PATCH] Fix memory leaks in wxHtmlParser unit test Remove the unnecessary, and actually harmful, overridden GetProduct(), as we must delete the pointer returned by the base class version to avoid leaking it. Also use wxScopedPtr to avoid leaking a test wxHtmlContainerCell. --- tests/html/htmlparser.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/html/htmlparser.cpp b/tests/html/htmlparser.cpp index f7814e0f0f..eb759ca73b 100644 --- a/tests/html/htmlparser.cpp +++ b/tests/html/htmlparser.cpp @@ -20,15 +20,13 @@ #endif // WX_PRECOMP #include "wx/html/winpars.h" +#include "wx/scopedptr.h" // Test that parsing invalid HTML simply fails but doesn't crash for example. TEST_CASE("wxHtmlParser::ParseInvalid", "[html][parser][error]") { class NullParser : public wxHtmlWinParser { - public: - virtual wxObject *GetProduct() wxOVERRIDE { return NULL; } - protected: virtual void AddText(const wxString& WXUNUSED(txt)) wxOVERRIDE { } }; @@ -37,17 +35,17 @@ TEST_CASE("wxHtmlParser::ParseInvalid", "[html][parser][error]") wxMemoryDC dc; p.SetDC(&dc); - p.Parse("<"); - p.Parse(" const top(new wxHtmlContainerCell(NULL)); wxHtmlContainerCell* const cont = new wxHtmlContainerCell(NULL); wxHtmlCell* const cell1 = new wxHtmlWordCell("Hello", dc); wxHtmlCell* const cell2 = new wxHtmlColourCell(*wxRED);