From 34217c0199938f50410e46b6d8bd91f297dc2e00 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 23 Feb 2016 09:16:50 -0500 Subject: [PATCH] Pcbnew: fix a crash when trying to export a footprint in a non writable directory, or if a non writable old file was existing. (Linux only. On Windows, the wxWidgets file dialog dectects this issue) --- pcbnew/librairi.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index a44e7c20e8..86210c8259 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -344,6 +344,15 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule ) pcb_io.Format( aModule ); FILE* fp = wxFopen( dlg.GetPath(), wxT( "wt" ) ); + + if( fp == NULL ) + { + wxMessageBox( wxString::Format( + _( "Unable to create or write file '%s'" ), + GetChars( dlg.GetPath() ) ) ); + return; + } + fprintf( fp, "%s", pcb_io.GetStringOutput( false ).c_str() ); fclose( fp ); }