aboutsummaryrefslogtreecommitdiff
path: root/tr8as.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-05 08:01:18 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-05 08:01:53 +0100
commit0699a11f0ffcd7c536bdb5ab45d898e3c6eb4a3c (patch)
tree5f5866887cfd2517c3ced69392f4332b042d6f9e /tr8as.c
parent030704970dcfc29c7c82e2aefb4f2646634cc24c (diff)
downloadtr8vm-0699a11f0ffcd7c536bdb5ab45d898e3c6eb4a3c.tar.gz
tr8vm-0699a11f0ffcd7c536bdb5ab45d898e3c6eb4a3c.zip
n case mstrdup failed, avoid free on NULL
Diffstat (limited to 'tr8as.c')
-rw-r--r--tr8as.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tr8as.c b/tr8as.c
index e150aeb..36418fa 100644
--- a/tr8as.c
+++ b/tr8as.c
@@ -1667,11 +1667,14 @@ static uint8_t asm(As *as, const char *filename, FILE *in)
rc = resolve(as);
for (i = 0; i < as->rcnt; i++)
- free((void *)as->refs[i].loc.filename);
+ if (as->refs[i].loc.filename)
+ free((void *)as->refs[i].loc.filename);
for (i = 0; i < as->dcnt; i++)
- free((void *)as->defs[i].loc.filename);
+ if (as->defs[i].loc.filename)
+ free((void *)as->defs[i].loc.filename);
for (i = 0; i < as->lcnt; i++)
- free((void *)as->labels[i].loc.filename);
+ if (as->labels[i].loc.filename)
+ free((void *)as->labels[i].loc.filename);
return rc;
}