1
0
mirror of synced 2024-11-24 07:40:17 +01:00

fix: Off-by-one error in "Export selection to file" (#1774)

### Problem description
Export selection to file would never finish and wouldn't export the last
byte.

### Implementation description
It was just a simple off by one when using the selection's end address
to calculate the remaining data size. Add one to the remaining size
calculation.

### Additional things
Fixes https://github.com/WerWolv/ImHex/issues/1733,
https://github.com/WerWolv/ImHex/issues/1619 and
https://github.com/WerWolv/ImHex/issues/1597.
This commit is contained in:
FireNX70 2024-06-26 22:44:10 +02:00 committed by GitHub
parent e132adad5d
commit 41820311cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -200,7 +200,7 @@ namespace hex::plugin::builtin {
auto selection = ImHexApi::HexEditor::getSelection();
for (u64 address = selection->getStartAddress(); address <= selection->getEndAddress(); address += bytes.size()) {
bytes.resize(std::min<u64>(bytes.size(), selection->getEndAddress() - address));
bytes.resize(std::min<u64>(bytes.size(), selection->getEndAddress() - address + 1));
provider->read(address, bytes.data(), bytes.size());
outputFile.writeVector(bytes);