mirror of
https://github.com/open-simh/simh.git
synced 2026-05-03 14:49:02 +00:00
Fix potential memory leak in error path reported by Michael Bloom
This commit is contained in:
@@ -2582,7 +2582,10 @@ t_stat xq_attach(UNIT* uptr, char* cptr)
|
|||||||
strcpy(tptr, cptr);
|
strcpy(tptr, cptr);
|
||||||
|
|
||||||
xq->var->etherface = (ETH_DEV *) malloc(sizeof(ETH_DEV));
|
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);
|
status = eth_open(xq->var->etherface, cptr, xq->dev, DBG_ETH);
|
||||||
if (status != SCPE_OK) {
|
if (status != SCPE_OK) {
|
||||||
|
|||||||
@@ -1571,7 +1571,10 @@ t_stat xu_attach(UNIT* uptr, char* cptr)
|
|||||||
strcpy(tptr, cptr);
|
strcpy(tptr, cptr);
|
||||||
|
|
||||||
xu->var->etherface = (ETH_DEV *) malloc(sizeof(ETH_DEV));
|
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);
|
status = eth_open(xu->var->etherface, cptr, xu->dev, DBG_ETH);
|
||||||
if (status != SCPE_OK) {
|
if (status != SCPE_OK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user