From 4cfedd1930d12f0463c8c532db1577962282a27a Mon Sep 17 00:00:00 2001 From: "Howard M. Harte" Date: Tue, 1 Nov 2022 21:08:20 -0700 Subject: [PATCH] AltairZ80: s100_hdc1001: fix bug in format. --- AltairZ80/s100_hdc1001.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AltairZ80/s100_hdc1001.c b/AltairZ80/s100_hdc1001.c index 0b59ae7b..9e58352e 100644 --- a/AltairZ80/s100_hdc1001.c +++ b/AltairZ80/s100_hdc1001.c @@ -722,11 +722,16 @@ static t_stat HDC1001_doCommand(void) file_offset *= pDrive->sectsize; /* Convert #sectors to byte offset */ fmtBuffer = calloc(data_len, sizeof(uint8)); + + if (fmtBuffer == NULL) { + return SCPE_IERR; + } + if (HDC1001_FORMAT_FILL_BYTE != 0) { 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) { r = SCPE_IOERR; }