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>
This commit is contained in:
Chang S. Bae 2018-09-14 18:51:56 +00:00 committed by Cyrill Gorcunov
parent b10435f06e
commit 17ffc1704b

View file

@ -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 */