• Andreas Rheinhardt's avatar
    avcodec/ttaenc: Fix undefined shift · 3ab488a5
    Andreas Rheinhardt authored
    ttaenc contained (1 << unary) - 1 as an argument for a function
    expecting an unsigned int. unary can be as big as 31 in this case.
    The type of the shift and the whole expression is int, because 1 fits
    into an integer, so that the behaviour is undefined if unary == 31
    as the result of the shift can't be represented in an int §. Subtraction
    by 1 (which makes the result of the whole expression representable in
    an int) doesn't change that this is undefined (it usually leads to
    signed integer overflow which is undefined, too).
    
    The solution is simple: Make 1 unsigned to change the type of the
    whole expression to unsigned int (as the function expects anyway).
    
    Fixes ticket #8153.
    
    §: This of course presupposes the common int range of -2^31..2^31-1
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    Reviewed-by: 's avatarPaul B Mahol <onemda@gmail.com>
    Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
    3ab488a5
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
ffbuild Loading commit data...
fftools Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libpostproc Loading commit data...
libswresample Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING.md Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL.md Loading commit data...
LICENSE.md Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
configure Loading commit data...