DISK: Fix Coverity identified error path problems

This commit is contained in:
Mark Pizzolato 2018-05-15 07:32:24 -07:00
parent 13b4f6563f
commit 2363300e64

View file

@ -1564,11 +1564,8 @@ switch (DK_GET_FMT (uptr)) { /* case on format */
} }
uptr->filename = (char *) calloc (CBUFSIZE, sizeof (char));/* alloc name buf */ uptr->filename = (char *) calloc (CBUFSIZE, sizeof (char));/* alloc name buf */
uptr->disk_ctx = ctx = (struct disk_context *)calloc(1, sizeof(struct disk_context)); uptr->disk_ctx = ctx = (struct disk_context *)calloc(1, sizeof(struct disk_context));
if ((uptr->filename == NULL) || (uptr->disk_ctx == NULL)) { if ((uptr->filename == NULL) || (uptr->disk_ctx == NULL))
free (uptr->filename);
free (uptr->disk_ctx);
return _err_return (uptr, SCPE_MEM); return _err_return (uptr, SCPE_MEM);
}
strncpy (uptr->filename, cptr, CBUFSIZE); /* save name */ strncpy (uptr->filename, cptr, CBUFSIZE); /* save name */
ctx->sector_size = (uint32)sector_size; /* save sector_size */ ctx->sector_size = (uint32)sector_size; /* save sector_size */
ctx->capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* save capacity units (word: 2, byte: 1) */ ctx->capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* save capacity units (word: 2, byte: 1) */