diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2018-06-01 21:05:45 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2018-06-01 21:05:45 -0700 |
commit | 3cb9068ee07fe15d4085f70110be31b6443f97ed (patch) | |
tree | 6a2bd9db57d17d50e9023b3d42472fbe30ac90b1 | |
parent | 69f0551f6f62f62e53dcbb0e7b6f3daaaa34159d (diff) | |
download | nasm-3cb9068ee07fe15d4085f70110be31b6443f97ed.tar.gz |
asm/directiv.c: fix bug in perm_alloc()
Fix dumb thinko in perm_alloc().
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | asm/directiv.c | 5 | ||||
-rw-r--r-- | asm/labels.c | 13 |
2 files changed, 14 insertions, 4 deletions
diff --git a/asm/directiv.c b/asm/directiv.c index b7c919d2..fa800b94 100644 --- a/asm/directiv.c +++ b/asm/directiv.c @@ -332,13 +332,14 @@ bool process_directives(char *directive) } if (nasm_isspace(*q)) { - sizestr = q = nasm_zap_spaces_fwd(q); + *q++ = '\0'; + sizestr = q = nasm_skip_spaces(q); q = strchr(q, ':'); } else { sizestr = NULL; } - if (*q == ':') { + if (q && *q == ':') { *q++ = '\0'; special = q; } else { diff --git a/asm/labels.c b/asm/labels.c index cde518d0..2275bdb7 100644 --- a/asm/labels.c +++ b/asm/labels.c @@ -345,6 +345,12 @@ handle_herelabel(const union label *lptr, int32_t *segment, int64_t *offset) static bool declare_label_lptr(union label *lptr, enum label_type type, const char *special) { + if (special && !special[0]) + special = NULL; + + printf("declare_label %s type %d special %s\n", + lptr->defn.label, lptr->defn.type, lptr->defn.special); + if (lptr->defn.type == type || (pass0 == 0 && lptr->defn.type == LBL_LOCAL)) { lptr->defn.type = type; @@ -514,6 +520,8 @@ static void init_block(union label *blk) static char * safe_alloc perm_alloc(size_t len) { + char *p; + if (perm_tail->size - perm_tail->usage < len) { size_t alloc_len = (len > PERMTS_SIZE) ? len : PERMTS_SIZE; perm_tail->next = nasm_malloc(PERMTS_HEADER + alloc_len); @@ -522,8 +530,9 @@ static char * safe_alloc perm_alloc(size_t len) perm_tail->size = alloc_len; perm_tail->usage = 0; } + p = perm_tail->data + perm_tail->usage; perm_tail->usage += len; - return perm_tail->data + perm_tail->usage; + return p; } static char *perm_copy(const char *string) @@ -542,7 +551,7 @@ static char *perm_copy(const char *string) return p; } -static char * safe_alloc +static char * perm_copy3(const char *s1, const char *s2, const char *s3) { char *p; |