From 58af5bc3a40807907c85a3cffaf6cdc4ec49d8a4 Mon Sep 17 00:00:00 2001 From: Jean-Noel Avila Date: Wed, 9 Nov 2016 09:46:35 +0100 Subject: [PATCH] Eeschema: Fix off-by-one in saving bitmaps --- common/class_bitmap_base.cpp | 5 ++--- eeschema/sch_legacy_plugin.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/common/class_bitmap_base.cpp b/common/class_bitmap_base.cpp index c563f1fc46..5cf46b4b10 100644 --- a/common/class_bitmap_base.cpp +++ b/common/class_bitmap_base.cpp @@ -107,9 +107,8 @@ bool BITMAP_BASE::SaveData( FILE* aFile ) const // Write binary data in hexadecimal form (ASCII) wxStreamBuffer* buffer = stream.GetOutputStreamBuffer(); char* begin = (char*) buffer->GetBufferStart(); - int ii; - for( ii = 0; begin <= buffer->GetBufferEnd(); begin++, ii++ ) + for( int ii = 0; begin < buffer->GetBufferEnd(); begin++, ii++ ) { if( ii >= 32 ) { @@ -140,7 +139,7 @@ void BITMAP_BASE::SaveData( wxArrayString& aPngStrings ) const char* begin = (char*) buffer->GetBufferStart(); wxString line; - for( int ii = 0; begin <= buffer->GetBufferEnd(); begin++, ii++ ) + for( int ii = 0; begin < buffer->GetBufferEnd(); begin++, ii++ ) { if( ii >= 32 ) { diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 3c96c098c0..e0786fb2d8 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -1707,7 +1707,7 @@ void SCH_LEGACY_PLUGIN::saveBitmap( SCH_BITMAP* aBitmap ) wxStreamBuffer* buffer = stream.GetOutputStreamBuffer(); char* begin = (char*) buffer->GetBufferStart(); - for( int ii = 0; begin <= buffer->GetBufferEnd(); begin++, ii++ ) + for( int ii = 0; begin < buffer->GetBufferEnd(); begin++, ii++ ) { if( ii >= 32 ) {