]> granicus.if.org Git - libjpeg-turbo/commitdiff
Fix UBSan warning in arithmetic decoder
authorDRC <information@libjpeg-turbo.org>
Thu, 22 Sep 2016 19:38:51 +0000 (14:38 -0500)
committerDRC <information@libjpeg-turbo.org>
Thu, 22 Sep 2016 19:40:41 +0000 (14:40 -0500)
Very similar to the ones that were fixed in the Huffman decoders in
8e9cef2e6f5156c4b055a04a8f979b7291fc6b7a.  These are innocuous.

Refer to https://bugzilla.mozilla.org/show_bug.cgi?id=1304567.

jdarith.c

index df3540eef54504e04bd030c26a01f226a5bd9a0c..ce0f920954dac20e97c9ebbaa28101c1eb611c5b 100644 (file)
--- a/jdarith.c
+++ b/jdarith.c
@@ -21,6 +21,9 @@
 #include "jpeglib.h"
 
 
+#define NEG_1 ((unsigned int)-1)
+
+
 /* Expanded entropy decoder object for arithmetic decoding. */
 
 typedef struct {
@@ -450,7 +453,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
   tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
 
   p1 = 1 << cinfo->Al;          /* 1 in the bit position being coded */
-  m1 = (-1) << cinfo->Al;       /* -1 in the bit position being coded */
+  m1 = (NEG_1) << cinfo->Al;    /* -1 in the bit position being coded */
 
   /* Establish EOBx (previous stage end-of-block) index */
   for (kex = cinfo->Se; kex > 0; kex--)