From 4ec3f18fda12621b5e18a869d322d179d0bbd904 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 4 Apr 2021 06:20:14 -0700 Subject: [PATCH] Return wxString for gfx importer messages Returning a reference to a temporary value crashes when the value is deallocated before use. Passing a full string fixes the crash and allows NVRO on the temporary value. --- pcbnew/import_gfx/dxf_import_plugin.h | 2 +- pcbnew/import_gfx/graphics_import_plugin.h | 2 +- pcbnew/import_gfx/graphics_importer.h | 2 +- pcbnew/import_gfx/svg_import_plugin.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pcbnew/import_gfx/dxf_import_plugin.h b/pcbnew/import_gfx/dxf_import_plugin.h index d4f8a74929..3e339bd63b 100644 --- a/pcbnew/import_gfx/dxf_import_plugin.h +++ b/pcbnew/import_gfx/dxf_import_plugin.h @@ -217,7 +217,7 @@ public: /** * @return the list of messages in one string. Each message ends by '\n' */ - const wxString& GetMessages() const override + wxString GetMessages() const override { return m_messages; } diff --git a/pcbnew/import_gfx/graphics_import_plugin.h b/pcbnew/import_gfx/graphics_import_plugin.h index ff21fc8f74..f146f2bc59 100644 --- a/pcbnew/import_gfx/graphics_import_plugin.h +++ b/pcbnew/import_gfx/graphics_import_plugin.h @@ -118,7 +118,7 @@ public: * * @return the list of messages in one string. Each message ends by '\n' */ - const virtual wxString& GetMessages() const = 0; + virtual wxString GetMessages() const = 0; protected: ///> Importer used to create objects representing the imported shapes. diff --git a/pcbnew/import_gfx/graphics_importer.h b/pcbnew/import_gfx/graphics_importer.h index a9b8d7a8c0..1ed2b10181 100644 --- a/pcbnew/import_gfx/graphics_importer.h +++ b/pcbnew/import_gfx/graphics_importer.h @@ -83,7 +83,7 @@ public: * * @return the list of messages in one string. Each message ends by '\n' */ - const wxString& GetMessages() const + wxString GetMessages() const { return m_plugin->GetMessages(); } diff --git a/pcbnew/import_gfx/svg_import_plugin.h b/pcbnew/import_gfx/svg_import_plugin.h index b1371b61ee..d4b1739613 100644 --- a/pcbnew/import_gfx/svg_import_plugin.h +++ b/pcbnew/import_gfx/svg_import_plugin.h @@ -52,7 +52,7 @@ public: /** * @return the list of messages in one string. Each message ends by '\n' */ - const wxString& GetMessages() const override + wxString GetMessages() const override { return m_messages; }