about summary refs log tree commit diff
path: root/converter/other/bmptopnm.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2016-06-17 01:52:03 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2016-06-17 01:52:03 +0000
commit1098aeb2abcc24e9a715d29708616dcf58ed5fad (patch)
treeb5762ce80ff7ead68602c06aa139110aabe39d6b /converter/other/bmptopnm.c
parent856ae491efd34dcb2fc136625b8051fe074d65d2 (diff)
downloadnetpbm-mirror-1098aeb2abcc24e9a715d29708616dcf58ed5fad.tar.gz
netpbm-mirror-1098aeb2abcc24e9a715d29708616dcf58ed5fad.tar.xz
netpbm-mirror-1098aeb2abcc24e9a715d29708616dcf58ed5fad.zip
Fix bug from revision 2770 on 16.05.09
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2790 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/bmptopnm.c')
-rw-r--r--converter/other/bmptopnm.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/converter/other/bmptopnm.c b/converter/other/bmptopnm.c
index 8c2b657e..c39b4fd7 100644
--- a/converter/other/bmptopnm.c
+++ b/converter/other/bmptopnm.c
@@ -717,37 +717,32 @@ bmpReadColormap(FILE *         const ifP,
  
    'class' is the class of BMP image - Windows or OS/2.
 -----------------------------------------------------------------------------*/
-
+    xel * const colormap = pnm_allocrow(MAX(1, cmapsize));
+    
     unsigned int i;
-
-    xel * colormap;
     unsigned int bytesRead;
 
-    colormap = pnm_allocrow(MAX(1,cmapsize));
-    
-    bytesRead = 0;  /* initial value */
-
-    for (i = 0; i < cmapsize; ++i) {
+    for (i = 0, bytesRead = 0; i < cmapsize; ++i) {
         /* There is a document that says the bytes are ordered R,G,B,Z,
            but in practice it appears to be the following instead:
         */
-        unsigned int r, g, b;
-        
-        b = GetByte(ifP);
-        g = GetByte(ifP);
-        r = GetByte(ifP);
+        unsigned int const b = GetByte(ifP);
+        unsigned int const g = GetByte(ifP);
+        unsigned int const r = GetByte(ifP);
+
+        unsigned int j;
 
         PNM_ASSIGN(colormap[i], r, g, b);
 
         bytesRead += 3;
 
-        for (i = 3; i < BMPlenrgb(class); ++i) {
+        for (j = 3; j < BMPlenrgb(class); ++j) {
             GetByte(ifP);
             bytesRead += 1;
         }
     }
 
-    *colormapP = colormap;
+    *colormapP  = colormap;
     *bytesReadP = bytesRead;
 }