Fix potential memory leak in error path reported by Michael Bloom
This commit is contained in:
parent
cf280ad8f7
commit
663b25818b
2 changed files with 8 additions and 2 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue