From e36f6953dc78ab24f6c589a0125d9c1cd097d846 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sat, 9 Sep 2017 05:46:24 +0000 Subject: [PATCH] Simplified a bit of C code. --- c/qrcodegen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/qrcodegen.c b/c/qrcodegen.c index 3ace1f0..1414118 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -990,9 +990,9 @@ testable int getTotalBits(const struct qrcodegen_Segment segs[], size_t len, int int ccbits = numCharCountBits(segs[i].mode, version); assert(0 <= ccbits && ccbits <= 16); // Fail if segment length value doesn't fit in the length field's bit-width - if (segs[i].numChars >= (1L << ccbits)) + if (numChars >= (1L << ccbits)) return -1; - long temp = 4L + ccbits + segs[i].bitLength; + long temp = 4L + ccbits + bitLength; if (temp > INT16_MAX - result) return -1; result += temp;