From: Peter Johnson Date: Thu, 21 Mar 2002 03:34:48 +0000 (-0000) Subject: Fix bug in align_section(): if a section has no bytecodes, last will be NULL! X-Git-Tag: v0.2.0~283 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ad58d8f334d4f94853c03cb178757655d77bcb7;p=yasm Fix bug in align_section(): if a section has no bytecodes, last will be NULL! svn path=/trunk/yasm/; revision=542 --- 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