Skip to content

Commit 234fa2a

Browse files
committed
decompress: Fix decompression when length takes 7 bits
This manifested as incorrect error messages from mpy-cross, like ``` $ mpy-cross doesnotexist.py OSError: [Errno 2] cno such file/director ``` The remaining bits in `b` must be shifted to the correct position before entering the loop. For most (all?) actual builds, compress_max_length_bits was 8 and the problem went unnoticed.
1 parent a78d00a commit 234fa2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

supervisor/shared/translate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ uint16_t decompress_length(const compressed_string_t *compressed) {
8686
char *decompress(const compressed_string_t *compressed, char *decompressed) {
8787
uint8_t this_byte = compress_max_length_bits / 8;
8888
uint8_t this_bit = 7 - compress_max_length_bits % 8;
89-
uint8_t b = (&compressed->data)[this_byte];
89+
uint8_t b = (&compressed->data)[this_byte] << (compress_max_length_bits % 8);
9090
uint16_t length = decompress_length(compressed);
9191

9292
// Stop one early because the last byte is always NULL.

0 commit comments

Comments
 (0)