diff options
author | wm4 <wm4@nowhere> | 2014-11-08 10:21:12 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-08 10:21:12 +0100 |
commit | 2a5c77df73b721d05e2a1331b79caa5a3a0c4969 (patch) | |
tree | 5b1c59f6e5f14a548708c6d31a364d04b84f7135 /demux | |
parent | 64f6e88c454d4c63b3bc45cf5f7d01d5006e67f0 (diff) | |
download | mpv-2a5c77df73b721d05e2a1331b79caa5a3a0c4969.tar.bz2 mpv-2a5c77df73b721d05e2a1331b79caa5a3a0c4969.tar.xz |
demux_mkv: fix undefined shifts
Found by clang sanitizer. Casting unsigned integers to signed integers
with same size has implementation defined behavior (it's even allowed to
crash), but it seems reasonable to expect that reasonable
implementations do a complement of 2 "conversion".
Diffstat (limited to 'demux')
-rw-r--r-- | demux/ebml.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/demux/ebml.c b/demux/ebml.c index 7e7765e425..d94aed5f64 100644 --- a/demux/ebml.c +++ b/demux/ebml.c @@ -173,7 +173,7 @@ uint64_t ebml_read_uint(stream_t *s) */ int64_t ebml_read_int(stream_t *s) { - int64_t value = 0; + uint64_t value = 0; uint64_t len; int l; @@ -189,7 +189,7 @@ int64_t ebml_read_int(stream_t *s) while (len--) value = (value << 8) | stream_read_char(s); - return value; + return (int64_t)value; // assume complement of 2 } /* @@ -328,12 +328,12 @@ static uint64_t ebml_parse_uint(uint8_t *data, int length) static int64_t ebml_parse_sint(uint8_t *data, int length) { assert(length >=1 && length <= 8); - int64_t r = 0; + uint64_t r = 0; if (*data & 0x80) r = -1; while (length--) r = (r << 8) | *data++; - return r; + return (int64_t)r; // assume complement of 2 } static double ebml_parse_float(uint8_t *data, int length) |