]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
wmadec: Use read_u32_be().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 28 Jan 2017 17:02:33 +0000 (18:02 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 25 Mar 2017 10:58:52 +0000 (11:58 +0100)
The shift operation in show_bits() was buggy because p[0] is promoted
to int, and the shift p[0] << 24 results in undefined behavior,
causing the sanitizer of gcc to complain:

bitstream.h:40:21: runtime error: left shift of 230 by 24 places cannot be represented in type 'int'

read_u32_be() gets this right.

bitstream.c
bitstream.h
wmadec_filter.c

index 638d19a3579b02053bd281e29e7f39d2bf54495c..9cd1273cfd578cf89492012b41cf236ecd32a38d 100644 (file)
@@ -19,6 +19,7 @@
 #include "error.h"
 #include "string.h"
 #include "wma.h"
+#include "portable_io.h"
 #include "bitstream.h"
 
 static inline uint32_t get_data(const void *table, int i, int size)
index 5875b0d090e6e8007d34766ee090950c819188dd..a6349861a55092fcdc1f957d7570621fd51e6834 100644 (file)
@@ -36,8 +36,8 @@ struct vlc {
 static inline uint32_t show_bits(struct getbit_context *gbc, int num)
 {
        int idx = gbc->index;
-       const uint8_t *p = gbc->buffer + (idx >> 3);
-       uint32_t x = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+       const char *p = (const char *)gbc->buffer + (idx >> 3);
+       uint32_t x = read_u32_be(p);
        return (x << (idx & 7)) >> (32 - num);
 }
 
index 4c7c047a482e2b3f256cfb8c12dcd6b4de3a7500..692ea0f3dde1d25996a874aff00e1a6a1f7b043d 100644 (file)
@@ -29,6 +29,7 @@
 #include "sched.h"
 #include "buffer_tree.h"
 #include "filter.h"
+#include "portable_io.h"
 #include "bitstream.h"
 #include "imdct.h"
 #include "wma.h"