Author: post
Date: 2013-01-27 12:28:00 +0100 (Sun, 27 Jan 2013)
New Revision: 506

Modified:
   RawSpeed/NikonDecompressor.cpp
Log:
Prevent underflow (values below 0) in Nikon Decompression. Bug #587.

Modified: RawSpeed/NikonDecompressor.cpp
===================================================================
--- RawSpeed/NikonDecompressor.cpp      2013-01-12 11:07:14 UTC (rev 505)
+++ RawSpeed/NikonDecompressor.cpp      2013-01-27 11:28:00 UTC (rev 506)
@@ -122,12 +122,12 @@
     pUp2[y&1] += HuffDecodeNikon();
     pLeft1 = pUp1[y&1];
     pLeft2 = pUp2[y&1];
-    dest[0] = curve[pLeft1&0x7fff] | ((uint32)curve[pLeft2&0x7fff] << 16);
+    dest[0] = curve[clampbits(pLeft1,15)] | 
((uint32)curve[clampbits(pLeft2,15)] << 16);
     for (x = 1; x < cw; x++) {
       bits->checkPos();
       pLeft1 += HuffDecodeNikon();
       pLeft2 += HuffDecodeNikon();
-      dest[x] = curve[pLeft1&0x7fff] | ((uint32)curve[pLeft2&0x7fff] << 16);
+      dest[x] = curve[clampbits(pLeft1,15)] | 
((uint32)curve[clampbits(pLeft2,15)] << 16);
     }
   }
 }


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to