Commit a3fe02b0 authored by mru's avatar mru

Avoid negative shifts in build_table()

A shift by a negative amount has undefined behaviour.  Even though
the result of this shift is never used, the shift itself could
cause an exception of some kind.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@21939 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 149a9ddb
......@@ -158,11 +158,12 @@ static int build_table(VLC *vlc, int table_nb_bits,
#endif
/* if code matches the prefix, it is in the table */
n -= n_prefix;
if (n > 0) {
if(flags & INIT_VLC_LE)
code_prefix2= code & (n_prefix>=32 ? 0xffffffff : (1 << n_prefix)-1);
else
code_prefix2= code >> n;
if (n > 0 && code_prefix2 == code_prefix) {
if (code_prefix2 == code_prefix) {
if (n <= table_nb_bits) {
/* no need to add another table */
j = (code << (table_nb_bits - n)) & (table_size - 1);
......@@ -197,6 +198,7 @@ static int build_table(VLC *vlc, int table_nb_bits,
}
}
}
}
/* second pass : fill auxillary tables recursively */
for(i=0;i<table_size;i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment