pcbnew, SVG import: fix an issue for SVG files using a CR+LF end of file
The issue was in a validity test working only if CR+LF is not replaced by LF Fixes #10096 https://gitlab.com/kicad/code/kicad/issues/10096
This commit is contained in:
parent
61d4a5bfbe
commit
f136f3d7ee
|
@ -56,8 +56,11 @@ bool SVG_IMPORT_PLUGIN::Load( const wxString& aFileName )
|
|||
{
|
||||
wxCHECK( m_importer, false );
|
||||
|
||||
// wxFopen takes care of unicode filenames across platforms
|
||||
FILE* fp = wxFopen( aFileName, wxT( "rt" ) );
|
||||
// 1- wxFopen takes care of unicode filenames across platforms
|
||||
// 2 - nanosvg (exactly nsvgParseFromFile) expects a binary file (exactly the CRLF eof must
|
||||
// not be replaced by LF and changes the byte count) in one validity test,
|
||||
// so open it in binary mode.
|
||||
FILE* fp = wxFopen( aFileName, wxT( "rb" ) );
|
||||
|
||||
if( fp == nullptr )
|
||||
return false;
|
||||
|
|
|
@ -3688,6 +3688,8 @@ NSVGimage* nsvgParseFromFile( FILE *fp, const char* units, float dpi )
|
|||
if( data == NULL )
|
||||
goto error;
|
||||
|
||||
// This test works only if fp is open in binary mode, i.e. if the CRLF eol is not
|
||||
// replaced by LF when reading the file
|
||||
if( fread( data, 1, size, fp ) != size )
|
||||
goto error;
|
||||
|
||||
|
|
Loading…
Reference in New Issue