Fix double-delete.

The JSON_SETTINGS stuff makes copies of the
JOBSET_DESTINATION.  That ends poorly when it
contains just a naked C++ pointer.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21227
This commit is contained in:
Jeff Young
2025-07-01 21:02:12 -06:00
parent 18d9e113a6
commit eafa1a7af0
3 changed files with 5 additions and 6 deletions
+3 -4
View File
@@ -32,6 +32,7 @@
#include <reporter.h>
#include <algorithm>
#include <memory>
const int jobsFileSchemaVersion = 1;
@@ -140,8 +141,6 @@ JOBSET_DESTINATION::~JOBSET_DESTINATION()
delete reporter;
m_lastRunReporters.clear();
delete m_outputHandler;
}
@@ -149,11 +148,11 @@ void JOBSET_DESTINATION::InitOutputHandler()
{
if( m_type == JOBSET_DESTINATION_T::FOLDER )
{
m_outputHandler = new JOBS_OUTPUT_FOLDER();
m_outputHandler = std::make_shared<JOBS_OUTPUT_FOLDER>( );
}
else if( m_type == JOBSET_DESTINATION_T::ARCHIVE )
{
m_outputHandler = new JOBS_OUTPUT_ARCHIVE();
m_outputHandler = std::make_shared<JOBS_OUTPUT_ARCHIVE>( );
}
}
+1 -1
View File
@@ -86,7 +86,7 @@ struct KICOMMON_API JOBSET_DESTINATION
wxString m_id;
JOBSET_DESTINATION_T m_type;
wxString m_description;
JOBS_OUTPUT_HANDLER* m_outputHandler;
std::shared_ptr<JOBS_OUTPUT_HANDLER> m_outputHandler;
std::vector<wxString> m_only;
wxString GetDescription() const;
+1 -1
View File
@@ -139,7 +139,7 @@ bool DIALOG_DESTINATION::TransferDataFromWindow()
if( m_destination->m_type == JOBSET_DESTINATION_T::ARCHIVE )
{
JOBS_OUTPUT_ARCHIVE* archive =
static_cast<JOBS_OUTPUT_ARCHIVE*>( m_destination->m_outputHandler );
static_cast<JOBS_OUTPUT_ARCHIVE*>( m_destination->m_outputHandler.get() );
archive->SetFormat( JOBS_OUTPUT_ARCHIVE::FORMAT::ZIP );
}