about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-05-02 18:12:54 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-05-02 18:12:54 +0000
commit3fb9822420a65f1fa543e99edb55244ddf2a333a (patch)
treef2ed68d5e11ed3e16422950b76d93625ed780f3c
parent16970c0de736133435e63a0efe43b860464199c4 (diff)
downloadnetpbm-mirror-3fb9822420a65f1fa543e99edb55244ddf2a333a.tar.gz
netpbm-mirror-3fb9822420a65f1fa543e99edb55244ddf2a333a.tar.xz
netpbm-mirror-3fb9822420a65f1fa543e99edb55244ddf2a333a.zip
Fix for block shorter than code
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@907 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/giftopnm.c17
-rw-r--r--doc/HISTORY8
2 files changed, 20 insertions, 5 deletions
diff --git a/converter/other/giftopnm.c b/converter/other/giftopnm.c
index df049bf3..32023dce 100644
--- a/converter/other/giftopnm.c
+++ b/converter/other/giftopnm.c
@@ -75,7 +75,8 @@ readFile(FILE *          const ifP,
         else if (feof(ifP))
             asprintfN(errorP, "End of file encountered");
         else
-            asprintfN(errorP, "Short read -- %u bytes of %u", bytesRead, len);
+            asprintfN(errorP, "Short read -- %u bytes of %u",
+                              (unsigned)bytesRead, (unsigned)len);
     }
 }
 
@@ -582,16 +583,22 @@ getCode_get(struct getCodeState * const gsP,
   Return the code read (assuming *eofP == FALSE and *errorP == NULL)
   as *codeP.
 -----------------------------------------------------------------------------*/
-    if ((gsP->curbit+codeSize) > gsP->bufCount*8 && !gsP->streamExhausted) 
+
+    *errorP = NULL;
+
+    while (gsP->curbit + codeSize > gsP->bufCount * 8 &&
+           !gsP->streamExhausted && !*errorP) 
         /* Not enough left in buffer to satisfy request.  Get the next
            data block into the buffer.
+
+           Note that a data block may be as small as one byte, so we may need
+           to do this multiple times to get the full code.  (This probably
+           never happens in practice).
         */
         getAnotherBlock(ifP, gsP, errorP);
-    else
-        *errorP = NULL;
 
     if (!*errorP) {
-        if ((gsP->curbit+codeSize) > gsP->bufCount*8) {
+        if (gsP->curbit + codeSize > gsP->bufCount * 8) {
             /* The buffer still doesn't have enough bits in it; that means
                there were no data blocks left to read.
             */
diff --git a/doc/HISTORY b/doc/HISTORY
index 4ec292d2..e5160673 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -17,6 +17,11 @@ not yet  BJH  Release 10.47.00
               output) has lower maxval than the input.  (Old code scales down
               to the new maxval before dithering).
 
+              giftopnm: fix for unlikely case of a block smaller than a code.
+
+              ilbmtoppm: fix some bug in interpreting ILBM input.
+              (due to wrong pm_uintFromBigend16()).  From 10.46.
+
               ximtoppm: fix crash in command line processing.
 
               ppmrainbow: exit with proper exit status upon failure.
@@ -40,6 +45,9 @@ not yet  BJH  Release 10.47.00
               Fix: remove inclusion of pm_c_util.h from sshopt.h, which is
               an exported interface header file, whereas pm_c_util.h is not.
 
+              Lots of changes to integer code, bit access, word access, etc.
+              None functional.  Some speedup.
+
 09.03.29 BJH  Release 10.46.00
 
               xwdtopnm: Add -cmapdump .