From 18b307c85949bd6c47d5a45dde6f45ed94a19f3b Mon Sep 17 00:00:00 2001 From: Morgan Date: Tue, 16 Sep 2025 10:00:40 -0600 Subject: [PATCH] Fix potential IndexOutOfBounds Exception Fix potential IndexOutOfBounds Exception --- main.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index 8f796a5..7cf1ac1 100644 --- a/main.py +++ b/main.py @@ -142,18 +142,9 @@ class BZZCompressor: # Here we copy bit by bit from earlier in the output buffer. # we use this instead of index slicing since the slice could lead to # data we are currently copying into the buffer + start_index = len(output_buffer) - int(displacement.to01(), 2) for i in range(length): - out_index = len(output_buffer) - copy_index = out_index - int(displacement.to01(), 2) - - # This shouldn't happen - if copy_index < 0: - print( - "Error decompressing file. copy_index is out of range" - ) - return - - output_buffer.append(output_buffer[copy_index]) + output_buffer.append(output_buffer[start_index + i]) num_flags = bitarray(bin(int(num_flags.to01(), 2) - 1)[2:].zfill(24))