diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-01-12 03:41:56 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-01-12 03:41:56 +0000 |
commit | 98f217dd9b7a4c6d1a93b2398ec1e16c61a97cf4 (patch) | |
tree | 9b3cc18b7f90337add827befff533f9d6ccb19ea | |
parent | 41b849297cd0d81229e60a726fe7f1bfad1bc304 (diff) | |
download | netpbm-mirror-98f217dd9b7a4c6d1a93b2398ec1e16c61a97cf4.tar.gz netpbm-mirror-98f217dd9b7a4c6d1a93b2398ec1e16c61a97cf4.tar.xz netpbm-mirror-98f217dd9b7a4c6d1a93b2398ec1e16c61a97cf4.zip |
Fix negative unsigned integer problem
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@202 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | doc/HISTORY | 5 | ||||
-rw-r--r-- | lib/libpbm3.c | 32 |
2 files changed, 24 insertions, 13 deletions
diff --git a/doc/HISTORY b/doc/HISTORY index 61437c32..1422a363 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -6,6 +6,11 @@ CHANGE HISTORY not yet BJH Release 10.38.0 + libnetpbm: fix buffer overrun with PBM images < 8 columns. + + configure: default to 'none' for Svgalib if it doesn't appear + to be installed. + add pamfixtrunc. ppmdraw: fix crash with use of freed storage. Thanks diff --git a/lib/libpbm3.c b/lib/libpbm3.c index a5d5ea62..a3ada015 100644 --- a/lib/libpbm3.c +++ b/lib/libpbm3.c @@ -132,6 +132,14 @@ packBitsWithMmxSse(FILE * const fileP, +static unsigned int +bitValue(unsigned char const byteValue) { + + return byteValue == 0 ? 0 : 1; +} + + + static void packBitsGeneric(FILE * const fileP, const bit * const bitrow, @@ -139,27 +147,25 @@ packBitsGeneric(FILE * const fileP, unsigned int const cols, unsigned int * const nextColP) { /*---------------------------------------------------------------------------- - Pack the bits of bitrow[] into byts at 'packedBits'. Going left to right, + Pack the bits of bitrow[] into bytes at 'packedBits'. Going left to right, stop when there aren't enough bits left to fill a whole byte. Return as *nextColP the number of the next column after the rightmost one we packed. Don't use any special CPU facilities to do the packing. -----------------------------------------------------------------------------*/ - int col; - - #define iszero(x) ((x) == 0 ? 0 : 1) + unsigned int col; - for (col = 0; col < cols-7; col += 8) + for (col = 0; col + 7 < cols; col += 8) packedBits[col/8] = ( - iszero(bitrow[col+0]) << 7 | - iszero(bitrow[col+1]) << 6 | - iszero(bitrow[col+2]) << 5 | - iszero(bitrow[col+3]) << 4 | - iszero(bitrow[col+4]) << 3 | - iszero(bitrow[col+5]) << 2 | - iszero(bitrow[col+6]) << 1 | - iszero(bitrow[col+7]) << 0 + bitValue(bitrow[col+0]) << 7 | + bitValue(bitrow[col+1]) << 6 | + bitValue(bitrow[col+2]) << 5 | + bitValue(bitrow[col+3]) << 4 | + bitValue(bitrow[col+4]) << 3 | + bitValue(bitrow[col+5]) << 2 | + bitValue(bitrow[col+6]) << 1 | + bitValue(bitrow[col+7]) << 0 ); *nextColP = col; } |