]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Free SCSI struct only after device use count becomes zero.
authorToni Wilen <twilen@winuae.net>
Sat, 30 Apr 2016 13:56:07 +0000 (16:56 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 30 Apr 2016 13:56:07 +0000 (16:56 +0300)
hardfile.cpp

index cd812d8a9dd917d0a3c17ed8fe466a92c9305fca..bb19121bd06308a5564642463e80aa52383352d5 100644 (file)
@@ -2112,10 +2112,10 @@ static uae_u32 REGPARAM2 hardfile_close (TrapContext *ctx)
 
        if (!hfpd)
                return 0;
-       scsi_free(hfpd->sd);
-       hfpd->sd = NULL;
        trap_put_word(ctx, hfpd->base + 32, trap_get_word(ctx, hfpd->base + 32) - 1);
        if (trap_get_word(ctx, hfpd->base + 32) == 0) {
+               scsi_free(hfpd->sd);
+               hfpd->sd = NULL;
                write_comm_pipe_pvoid(&hfpd->requests, NULL, 0);
                write_comm_pipe_pvoid(&hfpd->requests, NULL, 0);
                write_comm_pipe_u32(&hfpd->requests, 0, 1);