Konamiman / Nextor

A disk operating system for MSX computers, forked from MSX-DOS 2.31
Other
183 stars 33 forks source link

Fix: incorrect setting of UD_ACLU when freeing a FAT chain #96

Closed Konamiman closed 2 years ago

Konamiman commented 2 years ago

Nextor 2.1.1 Alpha 1 introduced a new mechanism to improve the performance of cluster chain allocation in large drives, by caching the value of the smallest free cluster number (https://github.com/Konamiman/Nextor/pull/68 and https://github.com/Konamiman/Nextor/pull/72).

There's however a problem. When freeing a FAT chain (while deleting a file) the value of the cached value in the unit descriptor of the drive is updated to the smallest cluster number freed, but the code doing this has a bug and instead, a random memory address is modified; for small cluster numbers this means that the Nextor code itself is overwritten and this caused the computer to crash.

This pull request fixes this problem. To test the fix, you can use an empty floppy/storage device (or an equivalent disk image in an emulator); creating and deleting a few files will end up causing a computer crash in Nextor 2.1.1 beta 1, which shouldn't happen when this fix is applied.