AltairZ80: s100_hdc1001: fix bug in format.

This commit is contained in:
Howard M. Harte 2022-11-01 21:08:20 -07:00
parent 9a1ca7f298
commit 4cfedd1930

View file

@ -722,11 +722,16 @@ static t_stat HDC1001_doCommand(void)
file_offset *= pDrive->sectsize; /* Convert #sectors to byte offset */ file_offset *= pDrive->sectsize; /* Convert #sectors to byte offset */
fmtBuffer = calloc(data_len, sizeof(uint8)); fmtBuffer = calloc(data_len, sizeof(uint8));
if (fmtBuffer == NULL) {
return SCPE_IERR;
}
if (HDC1001_FORMAT_FILL_BYTE != 0) { if (HDC1001_FORMAT_FILL_BYTE != 0) {
memset(fmtBuffer, HDC1001_FORMAT_FILL_BYTE, data_len); memset(fmtBuffer, HDC1001_FORMAT_FILL_BYTE, data_len);
} }
if (0 != (r = sim_fseek((pDrive->uptr)->fileref, file_offset, SEEK_SET))) { if (0 == (r = sim_fseek((pDrive->uptr)->fileref, file_offset, SEEK_SET))) {
if (sim_fwrite(fmtBuffer, 1, data_len, (pDrive->uptr)->fileref) != data_len) { if (sim_fwrite(fmtBuffer, 1, data_len, (pDrive->uptr)->fileref) != data_len) {
r = SCPE_IOERR; r = SCPE_IOERR;
} }