summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2022-03-31 15:21:08 -0400
committer AJR <ajrhacker@users.noreply.github.com>2022-03-31 15:21:14 -0400
commit51586b043c35f9af82810254a75da5a6b7fbc949 (patch)
treed8613de7f2ffdafaaab4fbe5fa715162282b8eb1 /src/mame/machine
parentf5d61ddcbe778ad5444fb57524d49325c2a862f8 (diff)
homelab.cpp, ssem.cpp, machine/z80bin.cpp: Eliminate use of fgetc in quickload processing
Diffstat (limited to 'src/mame/machine')
-rw-r--r--src/mame/machine/z80bin.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/mame/machine/z80bin.cpp b/src/mame/machine/z80bin.cpp
index 98489ca31a5..ac6c2290e12 100644
--- a/src/mame/machine/z80bin.cpp
+++ b/src/mame/machine/z80bin.cpp
@@ -10,7 +10,6 @@
image_init_result z80bin_load_file(device_image_interface &image, address_space &space, uint16_t &exec_addr, uint16_t &start_addr, uint16_t &end_addr)
{
- int ch = 0;
uint16_t args[3]{};
uint16_t i = 0U, j = 0U, size = 0U;
uint8_t data = 0U;
@@ -19,15 +18,10 @@ image_init_result z80bin_load_file(device_image_interface &image, address_space
image.fseek(7, SEEK_SET);
- while((ch = image.fgetc()) != 0x1A)
+ char ch = '\0';
+ uint32_t bytes = 0;
+ while ((bytes = image.fread(&ch, 1)) != 0 && ch != 0x1A)
{
- if (ch == EOF)
- {
- image.seterror(image_error::INVALIDIMAGE, "Unexpected EOF while getting file name");
- image.message(" Unexpected EOF while getting file name");
- return image_init_result::FAIL;
- }
-
if (ch != '\0')
{
if (i >= (std::size(pgmname) - 1))
@@ -42,6 +36,13 @@ image_init_result z80bin_load_file(device_image_interface &image, address_space
}
}
+ if (bytes == 0)
+ {
+ image.seterror(image_error::INVALIDIMAGE, "Unexpected EOF while getting file name");
+ image.message(" Unexpected EOF while getting file name");
+ return image_init_result::FAIL;
+ }
+
pgmname[i] = '\0'; /* terminate string with a null */
if (image.fread(args, sizeof(args)) != sizeof(args))