From 206a6311355ad75f3b455a23dfaf62fcbca0e670 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Fri, 16 Feb 2024 11:08:57 +0000 Subject: [PATCH] Ensure stream is valid before checking for Eagle XML tag Fixes https://gitlab.com/kicad/code/kicad/-/issues/16989 Fixes KICAD-7QQ --- eeschema/sch_io/eagle/sch_io_eagle.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp index 71c1a19fed..a4a7077b2c 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.cpp +++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp @@ -626,6 +626,12 @@ wxXmlDocument SCH_IO_EAGLE::loadXmlDocument( const wxString& aFileName ) wxXmlDocument xmlDocument; wxFFileInputStream stream( m_filename.GetFullPath() ); + if( !stream.IsOk() ) + { + THROW_IO_ERROR( + wxString::Format( _( "Unable to read file '%s'." ), m_filename.GetFullPath() ) ); + } + // read first line to check for Eagle XML format file wxTextInputStream text( stream ); wxString line = text.ReadLine(); @@ -637,7 +643,7 @@ wxXmlDocument SCH_IO_EAGLE::loadXmlDocument( const wxString& aFileName ) m_filename.GetFullPath() ) ); } - if( !stream.IsOk() || !xmlDocument.Load( stream ) ) + if( !xmlDocument.Load( stream ) ) { THROW_IO_ERROR( wxString::Format( _( "Unable to read file '%s'." ), m_filename.GetFullPath() ) );