From b4182cbc1922e2716f78eb14f07b561016519ff9 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Wed, 1 Apr 2020 19:27:49 +0100 Subject: [PATCH] Remove unneccessary length checks in Code1 Revokes commit #024490 and re-establishes commit #0c00ec Relating to #184 thanks to Milton Neal and Git Lost --- backend/code1.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/backend/code1.c b/backend/code1.c index 42ad9c64..bda1449a 100644 --- a/backend/code1.c +++ b/backend/code1.c @@ -441,11 +441,9 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne if (j == 13) { latch = 0; - if ((length - sp) >= 14) { - for (i = sp + 13; i < length; i++) { - if (!((source[i] >= '0') && (source[i] <= '9'))) { - latch = 1; - } + for (i = sp + 13; i < length; i++) { + if (!((source[i] >= '0') && (source[i] <= '9'))) { + latch = 1; } } @@ -492,11 +490,9 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne if (j == 7) { latch = 0; - if ((length - sp) >= 8) { - for (i = sp + 7; i < length; i++) { - if (!((source[sp + i] >= '0') && (source[sp + i] <= '9'))) { - latch = 1; - } + for (i = sp + 7; i < length; i++) { + if (!((source[i] >= '0') && (source[i] <= '9'))) { + latch = 1; } }