SCP: UNIT_BUFABLE isn't always set with UNIT_MUSTBUF
UNIT_BUFABLE without UNIT_MUSTBUF means that uptr->filebuf is managed outside of attach_unit's authority. The buffer copy must always be allocated if UNIT_BUFABLE is set so that there is space to store the initial loaded copy. Fix #1122
This commit is contained in:
parent
eac0e5680b
commit
d960c96f56
1 changed files with 6 additions and 4 deletions
10
scp.c
10
scp.c
|
@ -8154,16 +8154,18 @@ else {
|
|||
}
|
||||
if (uptr->flags & UNIT_BUFABLE) { /* buffer? */
|
||||
uint32 cap = ((uint32) uptr->capac) / dptr->aincr; /* effective size */
|
||||
|
||||
uptr->filebuf2 = calloc (cap, SZ_D (dptr)); /* allocate copy */
|
||||
if (uptr->filebuf2 == NULL)
|
||||
return attach_err (uptr, SCPE_MEM); /* error */
|
||||
if (uptr->flags & UNIT_MUSTBUF) { /* dyn alloc? */
|
||||
uptr->filebuf = calloc (cap, SZ_D (dptr)); /* allocate */
|
||||
uptr->filebuf2 = calloc (cap, SZ_D (dptr)); /* allocate copy */
|
||||
if ((uptr->filebuf == NULL) || /* no buffer? */
|
||||
(uptr->filebuf2 == NULL)) {
|
||||
if (uptr->filebuf == NULL) {
|
||||
free (uptr->filebuf);
|
||||
uptr->filebuf = NULL;
|
||||
free (uptr->filebuf2);
|
||||
uptr->filebuf2 = NULL;
|
||||
return attach_err (uptr, SCPE_MEM); /* error */
|
||||
return attach_err (uptr, SCPE_MEM); /* error */
|
||||
}
|
||||
}
|
||||
sim_messagef (SCPE_OK, "%s: buffering file in memory\n", sim_uname (uptr));
|
||||
|
|
Loading…
Add table
Reference in a new issue