Skip to content

Commit c8af731

Browse files
author
H. Peter Anvin
committed
outieee: fix segfault on empty input
Fix the IEEE backend crashing if the input file is empty. Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 55dc058 commit c8af731

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

output/outieee.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ----------------------------------------------------------------------- *
22
*
3-
* Copyright 1996-2016 The NASM Authors - All Rights Reserved
3+
* Copyright 1996-2022 The NASM Authors - All Rights Reserved
44
* See the file AUTHORS included with the NASM distribution for
55
* the specific copyright holders.
66
*
@@ -936,7 +936,7 @@ static void ieee_write_file(void)
936936
* Write the section headers
937937
*/
938938
seg = seghead;
939-
if (!debuginfo && !strcmp(seg->name, "??LINE"))
939+
if (!debuginfo && seg && !strcmp(seg->name, "??LINE"))
940940
seg = seg->next;
941941
while (seg) {
942942
char buf[256];
@@ -971,7 +971,7 @@ static void ieee_write_file(void)
971971
/*
972972
* write the start address if there is one
973973
*/
974-
if (ieee_entry_seg) {
974+
if (ieee_entry_seg && seghead) {
975975
for (seg = seghead; seg; seg = seg->next)
976976
if (seg->index == ieee_entry_seg)
977977
break;
@@ -1084,7 +1084,7 @@ static void ieee_write_file(void)
10841084
* put out section data;
10851085
*/
10861086
seg = seghead;
1087-
if (!debuginfo && !strcmp(seg->name, "??LINE"))
1087+
if (!debuginfo && seg && !strcmp(seg->name, "??LINE"))
10881088
seg = seg->next;
10891089
while (seg) {
10901090
if (seg->currentpos) {

0 commit comments

Comments
 (0)