Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / external / libjpeg-turbo / ubsan.patch
blob33d3c15a8b3cbcf9d663e58131cebd92c958c6dc
1 --- jcphuff.c
2 +++ jcphuff.c
3 @@ -14,6 +14,7 @@
4 * suspension.
5 */
7 +#include <stdint.h>
8 #define JPEG_INTERNALS
9 #include "jinclude.h"
10 #include "jpeglib.h"
11 @@ -255,7 +256,7 @@
12 if (c == 0xFF) { /* need to stuff a zero byte? */
13 emit_byte(entropy, 0);
15 - put_buffer <<= 8;
16 + put_buffer = (uint_least32_t) put_buffer << 8;
17 put_bits -= 8;
20 --- jdarith.c
21 +++ jdarith.c
22 @@ -306,7 +306,7 @@
23 while (m >>= 1)
24 if (arith_decode(cinfo, st)) v |= m;
25 v += 1; if (sign) v = -v;
26 - entropy->last_dc_val[ci] += v;
27 + entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
30 /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
31 @@ -564,7 +564,7 @@
32 while (m >>= 1)
33 if (arith_decode(cinfo, st)) v |= m;
34 v += 1; if (sign) v = -v;
35 - entropy->last_dc_val[ci] += v;
36 + entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff;
39 if (block)