1
0
mirror of https://github.com/open-simh/simh.git synced 2026-01-26 12:12:52 +00:00

sim_disk.c: only free filebuf if it was allocated here too.

PDP11/pdp11_rq.c re-uses ->filebuf as a sector buffer (under the #defined
name rqxb) and allocates it as such. If an RQ disk is detached and
another attached, this buffer would be lost and the pointer reset to
NULL. sim_disk.c would only allocate the buffer if UNIT_BUFABLE is set,
which means to buffer the whole disk. Since this rightly isn't set on RQ
disks, the pointer would remain NULL and segfaults would ensue.  See
open-simh issue 274.
add comment about safe re-use of filebuf
This commit is contained in:
Olaf Seibert
2023-07-15 15:47:39 +02:00
committed by Paul Koning
parent 1e371e7c98
commit 86ffe4bec2
2 changed files with 7 additions and 4 deletions

View File

@@ -172,6 +172,7 @@ extern int32 MMR2;
#define unit_plug u4 /* drive unit plug value */
#define io_status u5 /* io status from callback */
#define io_complete u6 /* io completion flag */
/* we can re-use filebuf because we don't set UNIT_BUFABLE in flags */
#define rqxb filebuf /* xfer buffer */
#define RQ_RMV(u) ((drv_tab[GET_DTYPE (u->flags)].flgs & RQDF_RMV)? \
UF_RMV: 0)