From: nasm-bot f. C. S. B. <cha...@in...> - 2018-09-15 20:09:24
|
Commit-ID: 17ffc1704b31654e3378626ca2a78cc85aed8e43 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=17ffc1704b31654e3378626ca2a78cc85aed8e43 Author: Chang S. Bae <cha...@in...> AuthorDate: Fri, 14 Sep 2018 18:51:56 +0000 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sat, 15 Sep 2018 23:04:30 +0300 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 <se...@gm...> Signed-off-by: Chang S. Bae <cha...@in...> --- output/outobj.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/output/outobj.c b/output/outobj.c index a223c60..beb1615 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 */ |