diff options
author | Chang S. Bae <chang.seok.bae@intel.com> | 2018-09-14 18:51:56 +0000 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2018-09-15 23:04:30 +0300 |
commit | 17ffc1704b31654e3378626ca2a78cc85aed8e43 (patch) | |
tree | daba5e93a7a11edd23000b10847c9c5bb309bb22 | |
parent | b10435f06e65df9e8fd2e1d8e8e62524e79ebec2 (diff) | |
download | nasm-17ffc1704b31654e3378626ca2a78cc85aed8e43.tar.gz |
obj: Fix to initialize segment list
Recent labeling mechanism changes seem to bring the case,
where segment() procedure is called when the segment list
is empty. Now, it will simply check and initalize the
segment list.
Reported-by: Ozkan Sezer <sezeroz@gmail.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
-rw-r--r-- | output/outobj.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/output/outobj.c b/output/outobj.c index a223c60a..beb1615c 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -1392,9 +1392,10 @@ static int32_t obj_segment(char *name, int pass, int *bits) attrs++; } - obj_idx = 1; - for (seg = seghead; seg; seg = seg->next) { - obj_idx++; + for (seg = seghead, obj_idx = 1; ; seg = seg->next, obj_idx++) { + if (!seg) + break; + if (!strcmp(seg->name, name)) { if (attrs > 0 && pass == 1) nasm_error(ERR_WARNING, "segment attributes specified on" @@ -1415,7 +1416,7 @@ static int32_t obj_segment(char *name, int pass, int *bits) seg->obj_index = obj_idx; seg->grp = NULL; any_segs = true; - seg->name = NULL; + seg->name = nasm_strdup(name); seg->currentpos = 0; seg->align = 1; /* default */ seg->use32 = false; /* default */ |