From de95d5bec1f764a21e6023d8e88e013080906a18 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 13 Mar 2017 17:25:42 -0700 Subject: [PATCH] SCP: Fix memory leak in error paths of RESTORE command (COVERITY) --- scp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scp.c b/scp.c index 38d1f568..f988b464 100644 --- a/scp.c +++ b/scp.c @@ -6141,10 +6141,14 @@ t_bool suppress_warning = ((sim_switches & SWMASK ('Q')) != 0); t_bool warned = FALSE; sim_switches &= ~(SWMASK ('F') | SWMASK ('D') | SWMASK ('Q')); /* remove digested switches */ -#define READ_S(xx) if (read_line ((xx), sizeof(xx), rfile) == NULL) \ - return SCPE_IOERR; -#define READ_I(xx) if (sim_fread (&xx, sizeof (xx), 1, rfile) == 0) \ - return SCPE_IOERR; +#define READ_S(xx) if (read_line ((xx), sizeof(xx), rfile) == NULL) { \ + r = SCPE_IOERR; \ + goto Cleanup_Return; \ + } +#define READ_I(xx) if (sim_fread (&xx, sizeof (xx), 1, rfile) == 0) { \ + r = SCPE_IOERR; \ + goto Cleanup_Return; \ + } fstat (fileno (rfile), &rstat); READ_S (buf); /* [V2.5+] read version */