             if rangeDecoder.decode(bitWithProb: &isRep[state], pointerData: &pointerData) != 0 {
                 if uncompressedSize == 0 {
                     // TODO: throw error
+                    break
                 }
                 if outWindow.isEmpty {
                     // TODO: throw error
+                    break
                 }
                 if rangeDecoder.decode(bitWithProb: &isRepG0[state], pointerData: &pointerData) == 0 {
                     if rangeDecoder.decode(bitWithProb: &isRep0Long[(state << Constants.numPosBitsMax) + posState],

            uncompressedSize -= len
            if isError {
                // TODO: throw error.
            }

        }

            if rangeDecoder.decode(bitWithProb: &isMatch[(state << Constants.numPosBitsMax) + posState], pointerData: &pointerData) == 0 {
                if uncompressedSize == 0 {
                    // TODO: throw error
                    break
                }

                // DECODE LITERAL:
