diff options
| author | Bluebie <a@creativepony.com> | 2012-10-04 10:43:45 +1000 | 
|---|---|---|
| committer | Bluebie <a@creativepony.com> | 2012-10-04 10:43:45 +1000 | 
| commit | c4918723c476db48c53cafe0b5373223cd1cca04 (patch) | |
| tree | a9aea5a2339641c2f9e070049aaf4b52343c1d04 | |
| parent | b8a41af251aa42faefa8ad33bd191259c896de1b (diff) | |
| download | micronucleus-c4918723c476db48c53cafe0b5373223cd1cca04.tar.gz micronucleus-c4918723c476db48c53cafe0b5373223cd1cca04.tar.bz2 micronucleus-c4918723c476db48c53cafe0b5373223cd1cca04.zip | |
Fix off by one error in ruby HexProgram ihex parser class
| -rw-r--r-- | ruby/micronucleus.rb | 12 | 
1 files changed, 8 insertions, 4 deletions
| diff --git a/ruby/micronucleus.rb b/ruby/micronucleus.rb index 3211d84..7dfafbd 100644 --- a/ruby/micronucleus.rb +++ b/ruby/micronucleus.rb @@ -127,11 +127,15 @@ class HexProgram    end    def binary +    bytes.pack('C*') +  end +   +  def bytes      highest_address = @bytes.keys.max - -    bytestring = Array.new(highest_address + 1) { |index| +     +    bytes = Array.new(highest_address + 1) { |index|        @bytes[index] -    }.pack('C*') +    }    end    protected @@ -143,7 +147,7 @@ class HexProgram        length = line[1..2].to_i(16) # usually 16 or 32        address = line[3..6].to_i(16) # 16-bit start address        record_type = line[7..8].to_i(16) -      data = line[9.. 9 + (length * 2)] +      data = line[9... 9 + (length * 2)]        checksum = line[9 + (length * 2).. 10 + (length * 2)].to_i(16)        checksum_section = line[1...9 + (length * 2)] | 
