From c4801a4dd4736094de40db382e74188233c6a667 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sat, 1 May 2021 14:26:47 -0400 Subject: [PATCH] Catch oom for graphics importer Because DXFs and SVGs could be nasty sized --- pcbnew/import_gfx/graphics_importer.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pcbnew/import_gfx/graphics_importer.cpp b/pcbnew/import_gfx/graphics_importer.cpp index 6192df1f2e..d51bcced3b 100644 --- a/pcbnew/import_gfx/graphics_importer.cpp +++ b/pcbnew/import_gfx/graphics_importer.cpp @@ -63,5 +63,18 @@ bool GRAPHICS_IMPORTER::Import( double aScale ) m_plugin->SetImporter( this ); - return m_plugin->Import(); + bool success = false; + + try + { + success = m_plugin->Import(); + } + catch( const std::bad_alloc& ) + { + // Memory exhaustion + // TODO report back an error message + return false; + } + + return success; }