aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-18 18:23:13 +0200
committerlemon <lsof@mailbox.org>2023-06-18 18:23:13 +0200
commit3990f0f2731c2289eaefefc9aff5bdcaee6c3289 (patch)
tree7d97c52dc8018cd07daea062f22f31fa5898a1f1 /ir.c
parent97621f5870d60722ae2bc13682c58d194bc20794 (diff)
fix memory bugs
Diffstat (limited to 'ir.c')
-rw-r--r--ir.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ir.c b/ir.c
index d214f55..08966a3 100644
--- a/ir.c
+++ b/ir.c
@@ -183,10 +183,12 @@ union ref
mkdatref(const char *name, uint siz, uint align, const void *bytes, uint n, bool deref)
{
struct irdat dat = { .align = align, .siz = siz, .name = name };
- if (siz <= 8) memcpy(dat.sdat, bytes, n < siz ? n : siz);
- else {
- while (((uchar *)bytes)[n-1] == 0) --n; /* nip trailing zeroes */
- if (n) vpushn(&dat.dat, bytes, n);
+ if (bytes) {
+ if (siz <= 8) memcpy(dat.sdat, bytes, n < siz ? n : siz);
+ else {
+ while (((uchar *)bytes)[n-1] == 0) --n; /* nip trailing zeroes */
+ if (n) vpushn(&dat.dat, bytes, n);
+ }
}
if (!name) {
extern const char *intern(const char *);