aboutsummaryrefslogtreecommitdiff
path: root/lpg/libqr/qr-bitstream.c
diff options
context:
space:
mode:
authorLeo Howell <leo@lwh.jp>2009-09-29 18:59:02 +0900
committerLeo Howell <leo@lwh.jp>2009-09-29 18:59:02 +0900
commit81eee33d754108de281fd279e0859de80a0e2586 (patch)
tree350172d3153def1dda2cf15ca448ce9a7d69e097 /lpg/libqr/qr-bitstream.c
parent7b61f48876af1c0a91c32355862e8bcb2e6d126c (diff)
downloadpdf-simple-sign-81eee33d754108de281fd279e0859de80a0e2586.tar.gz
pdf-simple-sign-81eee33d754108de281fd279e0859de80a0e2586.tar.xz
pdf-simple-sign-81eee33d754108de281fd279e0859de80a0e2586.zip
Fix bit/byte bug in bitstream
Diffstat (limited to 'lpg/libqr/qr-bitstream.c')
-rw-r--r--lpg/libqr/qr-bitstream.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lpg/libqr/qr-bitstream.c b/lpg/libqr/qr-bitstream.c
index 3df2549..b223f4c 100644
--- a/lpg/libqr/qr-bitstream.c
+++ b/lpg/libqr/qr-bitstream.c
@@ -30,14 +30,13 @@ static size_t bits_to_bytes(size_t bits)
static int ensure_available(struct qr_bitstream * stream, size_t bits)
{
size_t need_bits = stream->pos + bits;
- size_t need_bytes = need_bits / CHAR_BIT + ((need_bits % CHAR_BIT) ? 0 : 1);
size_t newsize;
- if (stream->bufsiz >= need_bytes)
+ if (stream->bufsiz * CHAR_BIT >= need_bits)
return 0;
- newsize = MAX(stream->bufsiz, 100);
- while (newsize < need_bytes)
+ newsize = MAX(stream->bufsiz, 100) * CHAR_BIT;
+ while (newsize < need_bits)
newsize *= 2;
return qr_bitstream_resize(stream, newsize);