SCP: Always clear uptr->fileref on detach

This commit is contained in:
Mark Pizzolato 2018-05-26 12:37:26 -07:00
parent 83234f1e9d
commit b1318f5c37

9
scp.c
View file

@ -6765,8 +6765,13 @@ if ((uptr->flags & UNIT_BUF) && (uptr->filebuf)) {
uptr->flags = uptr->flags & ~(UNIT_ATT | ((uptr->flags & UNIT_ROABLE) ? UNIT_RO : 0));
free (uptr->filename);
uptr->filename = NULL;
if (fclose (uptr->fileref) == EOF)
return SCPE_IOERR;
if (uptr->fileref) { /* Only close open file */
if (fclose (uptr->fileref) == EOF) {
uptr->fileref = NULL;
return SCPE_IOERR;
}
uptr->fileref = NULL;
}
return SCPE_OK;
}