From af90da9eba2a2c1673217c5d4ffee50e7807f5fa Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sat, 8 Jul 2017 18:37:39 +0300 Subject: [PATCH] Fix misaligned bytes from BitReader Added overrides of DWP functions which call skipUntilNextByte() before calling superclass functions therefore restoring old behavior. --- Sources/BitReader.swift | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Sources/BitReader.swift b/Sources/BitReader.swift index 00b80e05..008066f2 100644 --- a/Sources/BitReader.swift +++ b/Sources/BitReader.swift @@ -137,5 +137,30 @@ class BitReader: DataWithPointer { } self.index += 1 } + + override func alignedByte() -> UInt8 { + self.skipUntilNextByte() + return super.alignedByte() + } + + override func alignedBytes(count: Int) -> [UInt8] { + self.skipUntilNextByte() + return super.alignedBytes(count: count) + } + + override func intFromAlignedBytes(count: Int) -> Int { + self.skipUntilNextByte() + return super.intFromAlignedBytes(count: count) + } + + override func uint64FromAlignedBytes(count: UInt64) -> UInt64 { + self.skipUntilNextByte() + return super.uint64FromAlignedBytes(count: count) + } + + override func uint32FromAlignedBytes(count: UInt32) -> UInt32 { + self.skipUntilNextByte() + return super.uint32FromAlignedBytes(count: count) + } }