From 2ad58d8f334d4f94853c03cb178757655d77bcb7 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 21 Mar 2002 03:34:48 +0000 Subject: [PATCH] Fix bug in align_section(): if a section has no bytecodes, last will be NULL! svn path=/trunk/yasm/; revision=542 --- modules/objfmts/bin/bin-objfmt.c | 5 ++++- src/objfmts/bin/bin-objfmt.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/objfmts/bin/bin-objfmt.c b/modules/objfmts/bin/bin-objfmt.c index cd9b68c9..f3aabbae 100644 --- a/modules/objfmts/bin/bin-objfmt.c +++ b/modules/objfmts/bin/bin-objfmt.c @@ -70,7 +70,10 @@ bin_objfmt_align_section(section *sect, section *prevsect, unsigned long base, * plus its length. Add the start and size together to get the new start. */ last = bcs_last(section_get_bytecodes(prevsect)); - *prevsectlen = last->offset + last->len; + if (last) + *prevsectlen = last->offset + last->len; + else + *prevsectlen = 0; start = base + *prevsectlen; /* Round new start up to alignment of .data section, and adjust textlen to diff --git a/src/objfmts/bin/bin-objfmt.c b/src/objfmts/bin/bin-objfmt.c index cd9b68c9..f3aabbae 100644 --- a/src/objfmts/bin/bin-objfmt.c +++ b/src/objfmts/bin/bin-objfmt.c @@ -70,7 +70,10 @@ bin_objfmt_align_section(section *sect, section *prevsect, unsigned long base, * plus its length. Add the start and size together to get the new start. */ last = bcs_last(section_get_bytecodes(prevsect)); - *prevsectlen = last->offset + last->len; + if (last) + *prevsectlen = last->offset + last->len; + else + *prevsectlen = 0; start = base + *prevsectlen; /* Round new start up to alignment of .data section, and adjust textlen to -- 2.40.0