This file is part of MXE.
See index.html for further information.
Taken from libdca svn: svn://svn.videolan.org/libdca/trunk.
r88 | sam | 2008-07-19 22:26:13 +0000 (Sat, 19 Jul 2008) | 2 lines
* bitstream.c: fix random crashes caused by invalid 32-bit shifts on 32-bit
values.
--- libdca.orig/libdca/bitstream.c
+++ libdca/libdca/bitstream.c
@@ -25,6 +25,7 @@
#include "config.h"
+#include
#include
#include "dca.h"
@@ -46,7 +47,7 @@
state->bigendian_mode = bigendian_mode;
bitstream_get (state, align * 8);
}
-#include
+
static inline void bitstream_fill_current (dca_state_t * state)
{
uint32_t tmp;
@@ -76,12 +77,14 @@
uint32_t dca_bitstream_get_bh (dca_state_t * state, uint32_t num_bits)
{
- uint32_t result;
-
- num_bits -= state->bits_left;
+ uint32_t result = 0;
- result = ((state->current_word << (32 - state->bits_left)) >>
- (32 - state->bits_left));
+ if (state->bits_left)
+ {
+ num_bits -= state->bits_left;
+ result = ((state->current_word << (32 - state->bits_left)) >>
+ (32 - state->bits_left));
+ }
if ( !state->word_mode && num_bits > 28 ) {
bitstream_fill_current (state);