diff options
-rw-r--r-- | doc/HISTORY | 3 | ||||
-rw-r--r-- | lib/libpam.c | 19 |
2 files changed, 8 insertions, 14 deletions
diff --git a/doc/HISTORY b/doc/HISTORY index 4d721d37..b6d2b8d7 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -6,6 +6,9 @@ CHANGE HISTORY not yet BJH Release 10.45.00 + pnm_createBlackTuple(): fix array bounds violation with + PBM, PGM. + pnmtoddif: fix crash with any PGM input. pgmnoise: fix bug: never generates full white pixel. diff --git a/lib/libpam.c b/lib/libpam.c index 9e96029a..ab75fab6 100644 --- a/lib/libpam.c +++ b/lib/libpam.c @@ -195,21 +195,12 @@ pnm_createBlackTuple(const struct pam * const pamP, Create a "black" tuple. By that we mean a tuple all of whose elements are zero. If it's an RGB, grayscale, or b&w pixel, that means it's black. -----------------------------------------------------------------------------*/ + unsigned int i; + *blackTupleP = pnm_allocpamtuple(pamP); - if (pamP->format == PAM_FORMAT) { - /* In this format, we don't know the meaning of "black", so we - just punt. - */ - int i; - for (i = 0; i < pamP->depth; i++) - (*blackTupleP)[i] = 0; - } else { - xel black_xel; - black_xel = pnm_blackxel(pamP->maxval, pamP->format); - (*blackTupleP)[0] = PPM_GETR(black_xel); - (*blackTupleP)[1] = PPM_GETG(black_xel); - (*blackTupleP)[2] = PPM_GETB(black_xel); - } + + for (i = 0; i < pamP->depth; ++i) + (*blackTupleP)[i] = 0; } |