From 2758acfd4265f295c14a5bf009fa742e4abad131 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 1 Dec 2021 13:36:28 +0100 Subject: [PATCH] Fix compatibility with some old V4 schematic files. From master branch, commit #bfe59581 --- eeschema/sch_legacy_plugin.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 2f5483a1fb..f51b754772 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 CERN - * Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. * * @author Wayne Stambaugh * @@ -1112,9 +1112,13 @@ SCH_BITMAP* SCH_LEGACY_PLUGIN::loadBitmap( FILE_LINE_READER& aReader ) // Read PNG data, stored in hexadecimal, // each byte = 2 hexadecimal digits and a space between 2 bytes // and put it in memory stream buffer + // Note: + // Some old files created by the V4 schematic versions have a extra + // "$EndBitmap" at the end of the hexadecimal data. (Probably due to + // a bug). So discard it int len = strlen( line ); - for( ; len > 0 && !isspace( *line ); len -= 3, line += 3 ) + for( ; len > 0 && !isspace( *line ) && '$' != *line; len -= 3, line += 3 ) { int value = 0;