summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-07-26 15:29:09 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-07-26 15:29:09 -0700
commit7ad24562dccca867d9ba591ac7dd242456003c5b (patch)
tree8103d37019b99d0ad9278b7dbff2981861a99268
parent54dd03bfe56d6f23e423ed65054b329e1830ece1 (diff)
downloadnasm-7ad24562dccca867d9ba591ac7dd242456003c5b.tar.gz
BR 2827397: fix invalid C in outcoff AddExports()
The construct: if (i == nsects) directive_sec = sects[coff_make_section (EXPORT_SECTION_NAME, EXPORT_SECTION_FLAGS)]; ... where coff_make_section() can change the global variable "sects" is undefined C, since there is no sequence point involved in the [] operator, and it is therefore fully permitted for the C compiler to read the sects variable first. Change this construct into two statements to enforce defined behavior; this also ends up with the code slightly simpler. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--output/outcoff.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/output/outcoff.c b/output/outcoff.c
index b27cc94e..22cb3e88 100644
--- a/output/outcoff.c
+++ b/output/outcoff.c
@@ -674,16 +674,16 @@ void AddExport(char *name)
strcpy(newS->String, name);
if (rvp == NULL) {
int i;
- for (i = 0; i < nsects; i++)
+ for (i = 0; i < nsects; i++) {
if (!strcmp(EXPORT_SECTION_NAME, sects[i]->name))
break;
+ }
+
if (i == nsects)
- directive_sec =
- sects[coff_make_section
- (EXPORT_SECTION_NAME, EXPORT_SECTION_FLAGS)];
- else
- directive_sec = sects[i];
+ i = coff_make_section(EXPORT_SECTION_NAME, EXPORT_SECTION_FLAGS);
+
+ directive_sec = sects[i];
Exports = newS;
} else {
while (rvp->Next) {