From 276cb1cf47a5d16376d07b936cc804f283cc8910 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 17 May 2015 23:09:18 +0000 Subject: Make pbm_cleanrowend_packed() work with zero-width images git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2490 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/libpbm2.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/libpbm2.c b/lib/libpbm2.c index e12b1e33..503fd6c9 100644 --- a/lib/libpbm2.c +++ b/lib/libpbm2.c @@ -268,15 +268,16 @@ pbm_cleanrowend_packed(unsigned char * const packedBits, /*---------------------------------------------------------------------------- Set fractional "don't care" bits at end of row to zero. ----------------------------------------------------------------------------*/ - unsigned int const last = pbm_packed_bytes(cols) - 1; unsigned int const bitsPerChar = 8; - assert(cols > 0); - if (cols % bitsPerChar > 0) { - packedBits[last] >>= bitsPerChar - cols % bitsPerChar; - packedBits[last] <<= bitsPerChar - cols % bitsPerChar; - } + unsigned int const last = pbm_packed_bytes(cols) - 1; + + assert(pbm_packed_bytes(cols) > 0); + + packedBits[last] >>= bitsPerChar - cols % bitsPerChar; + packedBits[last] <<= bitsPerChar - cols % bitsPerChar; + } } -- cgit 1.4.1