From 1600865926607ff05d8bd078cd1d952891d724dc Mon Sep 17 00:00:00 2001 From: George Tasker Date: Sat, 21 Apr 2001 18:02:57 +0000 Subject: [PATCH] Fixed a possible double deletion of 'file' git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/xml/xmlres.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/contrib/src/xml/xmlres.cpp b/contrib/src/xml/xmlres.cpp index 3acb28f213..19c6eaf4cf 100644 --- a/contrib/src/xml/xmlres.cpp +++ b/contrib/src/xml/xmlres.cpp @@ -255,7 +255,7 @@ void wxXmlResource::UpdateResources() { bool modif; # if wxUSE_FILESYSTEM - wxFSFile *file; + wxFSFile *file = NULL; wxFileSystem fsys; # endif @@ -270,7 +270,7 @@ void wxXmlResource::UpdateResources() modif = file && file->GetModificationTime() > m_Data[i].Time; if (!file) wxLogError(_("Cannot open file '%s'."), m_Data[i].File.c_str()); - delete file; + wxDELETE(file); # else modif = wxDateTime(wxFileModificationTime(m_Data[i].File)) > m_Data[i].Time; # endif @@ -278,11 +278,12 @@ void wxXmlResource::UpdateResources() if (modif) { - wxInputStream *stream; + wxInputStream *stream = NULL; # if wxUSE_FILESYSTEM file = fsys.OpenFile(m_Data[i].File); - stream = file->GetStream(); + if (file) + stream = file->GetStream(); # else stream = new wxFileInputStream(m_Data[i].File); # endif @@ -295,22 +296,23 @@ void wxXmlResource::UpdateResources() if (!stream || !m_Data[i].Doc->Load(*stream)) { wxLogError(_("Cannot load resources from file '%s'."), m_Data[i].File.c_str()); - delete m_Data[i].Doc; - m_Data[i].Doc = NULL; + wxDELETE(m_Data[i].Doc); } else if (m_Data[i].Doc->GetRoot()->GetName() != wxT("resource")) { wxLogError(_("Invalid XML resource '%s': doesn't have root node 'resource'."), m_Data[i].File.c_str()); - delete m_Data[i].Doc; - m_Data[i].Doc = NULL; + wxDELETE(m_Data[i].Doc); } else + { ProcessPlatformProperty(m_Data[i].Doc->GetRoot()); + m_Data[i].Time = file->GetModificationTime(); + } # if wxUSE_FILESYSTEM - delete file; + wxDELETE(file); # else - delete stream; + wxDELETE(stream); # endif } } -- 2.45.2