From 663b25818bd7143b477fc4c1e2358cebb7b38e6f Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 20 Mar 2012 18:57:02 -0700 Subject: [PATCH] Fix potential memory leak in error path reported by Michael Bloom --- PDP11/pdp11_xq.c | 5 ++++- PDP11/pdp11_xu.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/PDP11/pdp11_xq.c b/PDP11/pdp11_xq.c index f3b3ce1f..e9a05ae4 100644 --- a/PDP11/pdp11_xq.c +++ b/PDP11/pdp11_xq.c @@ -2582,7 +2582,10 @@ t_stat xq_attach(UNIT* uptr, char* cptr) strcpy(tptr, cptr); xq->var->etherface = (ETH_DEV *) malloc(sizeof(ETH_DEV)); - if (!xq->var->etherface) return SCPE_MEM; + if (!xq->var->etherface) { + free(tptr); + return SCPE_MEM; + } status = eth_open(xq->var->etherface, cptr, xq->dev, DBG_ETH); if (status != SCPE_OK) { diff --git a/PDP11/pdp11_xu.c b/PDP11/pdp11_xu.c index 05bccaed..28dc50e0 100644 --- a/PDP11/pdp11_xu.c +++ b/PDP11/pdp11_xu.c @@ -1571,7 +1571,10 @@ t_stat xu_attach(UNIT* uptr, char* cptr) strcpy(tptr, cptr); xu->var->etherface = (ETH_DEV *) malloc(sizeof(ETH_DEV)); - if (!xu->var->etherface) return SCPE_MEM; + if (!xu->var->etherface) { + free(tptr); + return SCPE_MEM; + } status = eth_open(xu->var->etherface, cptr, xu->dev, DBG_ETH); if (status != SCPE_OK) {