From e6bef92ab7e35a99f2dda84d9bbacd08b79d4984 Mon Sep 17 00:00:00 2001 From: Michael Hrivnak Date: Tue, 23 Oct 2012 19:49:23 -0400 Subject: [PATCH] fixed bug where 4 bytes of data would be written with only 3 expected. --- thing.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/thing.rb b/thing.rb index dac966e..67f7093 100755 --- a/thing.rb +++ b/thing.rb @@ -390,6 +390,10 @@ if $0 == __FILE__ else bits = Math.log(node_count, 2).ceil bytes = (bits / 8).ceil + if bytes == 3 + # must write this as a 32-bit int + bytes = 4 + end file.write([128 + bytes].pack("C")) # get the correct integer directive for pack() @@ -400,7 +404,7 @@ if $0 == __FILE__ when 2 # 16-bit unsigned big-endian directive = "n" - when 3..4 + when 4 # 32-bit unsigned big-endian directive = "N" else