diff options
| author | 2023-06-18 18:23:13 +0200 | |
|---|---|---|
| committer | 2023-06-18 18:23:13 +0200 | |
| commit | 3990f0f2731c2289eaefefc9aff5bdcaee6c3289 (patch) | |
| tree | 7d97c52dc8018cd07daea062f22f31fa5898a1f1 /ir.c | |
| parent | 97621f5870d60722ae2bc13682c58d194bc20794 (diff) | |
fix memory bugs
Diffstat (limited to 'ir.c')
| -rw-r--r-- | ir.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 *); |