From 4c758a440aabe717b2e45f2f4b64ffa99c22eea1 Mon Sep 17 00:00:00 2001
From: Florian Sundermann <boombuler@googlemail.com>
Date: Thu, 12 Dec 2013 09:08:33 +0100
Subject: [PATCH] fixed bug with reminder bits in some qr versions

---
 qr/encoder.go | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/qr/encoder.go b/qr/encoder.go
index da18951..6517b09 100644
--- a/qr/encoder.go
+++ b/qr/encoder.go
@@ -109,13 +109,17 @@ func render(data []byte, vi *versionInfo) *qrcode {
 	var curBitNo int = 0
 
 	for pos := range itterateModules(occupied) {
+		var curBit bool
 		if curBitNo < len(data)*8 {
-			curBit := ((data[curBitNo/8] >> uint(7-(curBitNo%8))) & 1) == 1
-			for i := 0; i < 8; i++ {
-				setMasked(pos.X, pos.Y, curBit, i, results[i].Set)
-			}
-			curBitNo += 1
+			curBit = ((data[curBitNo/8] >> uint(7-(curBitNo%8))) & 1) == 1
+		} else {
+			curBit = false
 		}
+
+		for i := 0; i < 8; i++ {
+			setMasked(pos.X, pos.Y, curBit, i, results[i].Set)
+		}
+		curBitNo += 1
 	}
 
 	lowestPenalty := ^uint(0)