From 9553e96f8a99cd6a2b24fba2b439c5829bb4ef39 Mon Sep 17 00:00:00 2001 From: Boris Zentner Date: Sun, 22 May 2016 21:53:22 +0200 Subject: [PATCH] Fix of by one errors when searching from right to left. --- backend/aztec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/aztec.c b/backend/aztec.c index c59836ac..6c5903d6 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -220,7 +220,7 @@ static int aztec_text_process(const unsigned char source[], const unsigned int s } /* look for adjacent blocks which can use the same table (right to left search) */ - for (i = blocks - 1; i > 0; i--) { + for (i = blocks - 1 - 1; i >= 0; i--) { if (blockmap[0][i] & blockmap[0][i + 1]) { blockmap[0][i] = (blockmap[0][i] & blockmap[0][i + 1]); } @@ -247,7 +247,7 @@ static int aztec_text_process(const unsigned char source[], const unsigned int s do { if (blockmap[0][i] == blockmap[0][i + 1]) { blockmap[1][i] += blockmap[1][i + 1]; - for (j = i + 1; j < blocks; j++) { + for (j = i + 1; j < blocks - 1; j++) { blockmap[0][j] = blockmap[0][j + 1]; blockmap[1][j] = blockmap[1][j + 1]; } @@ -255,7 +255,7 @@ static int aztec_text_process(const unsigned char source[], const unsigned int s } else { i++; } - } while (i < blocks); + } while (i < blocks - 1); } /* Put the adjusted block data back into typemap */ @@ -1665,4 +1665,4 @@ int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length) symbol->width = 11; return 0; -} \ No newline at end of file +}