summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2021-01-31 19:13:31 +0100
committer Olivier Galibert <galibert@pobox.com>2021-01-31 19:15:16 +0100
commit9bb34aec209c547e56d90bdcfabf2e10c209f7d1 (patch)
tree6ce1ad1e2ea9bac2ef5099a4f8de58a7cef68efb
parent4790fcba212891cff597c3ed16632b40411f460d (diff)
flopimg: Fix wrapping on mac sector extraction
-rw-r--r--src/lib/formats/flopimg.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/formats/flopimg.cpp b/src/lib/formats/flopimg.cpp
index 0bdec18d201..9322551124b 100644
--- a/src/lib/formats/flopimg.cpp
+++ b/src/lib/formats/flopimg.cpp
@@ -2986,8 +2986,14 @@ std::vector<std::vector<uint8_t>> floppy_image_format_t::extract_sectors_from_tr
auto &sdata = sector_data[se];
uint8_t ca = 0, cb = 0, cc = 0;
- uint32_t hstate = (nib[pos] << 8) | nib[pos + 1];
- pos += 2;
+ uint32_t hstate = (nib[pos] << 8);
+ pos ++;
+ if(pos == nib.size())
+ pos = 0;
+ hstate |= nib[pos];
+ pos ++;
+ if(pos == nib.size())
+ pos = 0;
for(;;) {
hstate = ((hstate << 8) | nib[pos]) & 0xffffff;
pos ++;