From d47216212c57a23a40ac9f2b5853306ea610df86 Mon Sep 17 00:00:00 2001 From: "Howard M. Harte" Date: Sat, 1 Apr 2023 07:01:08 -0700 Subject: [PATCH] sim_imd: Resolve warnings. --- sim_imd.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sim_imd.c b/sim_imd.c index bb3f00d5..b9794d2a 100644 --- a/sim_imd.c +++ b/sim_imd.c @@ -1,6 +1,6 @@ /************************************************************************* * * - * Copyright (c) 2007-2022 Howard M. Harte. * + * Copyright (c) 2007-2023 Howard M. Harte. * * https://github.com/hharte * * * * Permission is hereby granted, free of charge, to any person obtaining * @@ -55,7 +55,12 @@ DISK_INFO *diskOpenEx(FILE *fileref, uint32 isVerbose, DEVICE *device, uint32 de { DISK_INFO *myDisk = NULL; - myDisk = (DISK_INFO *)malloc(sizeof(DISK_INFO)); + myDisk = (DISK_INFO*)calloc(1, sizeof(DISK_INFO)); + if (myDisk == NULL) { + sim_printf("%s: %s(): memory allocation failure.\n", __FILE__, __FUNCTION__); + return NULL; + } + myDisk->file = fileref; myDisk->device = device; myDisk->debugmask = debugmask; @@ -765,6 +770,12 @@ t_stat trackWrite(DISK_INFO *myDisk, */ dataLen = sectorLen + 1; sectorData = (uint8 *)malloc(dataLen); + + if (sectorData == NULL) { + sim_printf("%s: %s(): memory allocation failure.\n", __FILE__, __FUNCTION__); + return SCPE_MEM; + } + memset(sectorData, fillbyte, dataLen); sectorData[0] = SECT_RECORD_NORM;