diff options
author | v0lt <v0lt@rambler.ru> | 2013-02-02 00:29:06 +0400 |
---|---|---|
committer | v0lt <v0lt@rambler.ru> | 2013-02-02 00:31:39 +0400 |
commit | 68ffc9799616f7ec6256cb1ff99a7377474adab7 (patch) | |
tree | 53d2986598f6665bb1fec85d047f58f8a5131e7c /src/filters/parser/BaseSplitter | |
parent | 148d6384a30a2ff50742f3774d7dd64e53faa103 (diff) |
Fixed incorrect CBaseSplitterFile::BitRead function on x64.
Diffstat (limited to 'src/filters/parser/BaseSplitter')
-rw-r--r-- | src/filters/parser/BaseSplitter/BaseSplitterFile.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp index 4bc7c0e51..ed40990be 100644 --- a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp +++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp @@ -189,7 +189,14 @@ UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek) int bitlen = m_bitlen - nBits;
- UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
+ UINT64 ret;
+ // The shift to 64 bits can give incorrect results.
+ // "The behavior is undefined if the right operand is negative, or greater than or equal to the length in bits of the promoted left operand."
+ if (nBits == 64) {
+ ret = m_bitbuff;
+ } else {
+ ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
+ }
if (!fPeek) {
m_bitbuff &= ((1ui64 << bitlen) - 1);
|