]> granicus.if.org Git - yasm/commitdiff
Fix bug in align_section(): if a section has no bytecodes, last will be NULL!
authorPeter Johnson <peter@tortall.net>
Thu, 21 Mar 2002 03:34:48 +0000 (03:34 -0000)
committerPeter Johnson <peter@tortall.net>
Thu, 21 Mar 2002 03:34:48 +0000 (03:34 -0000)
svn path=/trunk/yasm/; revision=542

modules/objfmts/bin/bin-objfmt.c
src/objfmts/bin/bin-objfmt.c

index cd9b68c9c289f0443b80374bc180f9ef3ae855c6..f3aabbae942621e5fbe80430a23a0c8d77474b02 100644 (file)
@@ -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
index cd9b68c9c289f0443b80374bc180f9ef3ae855c6..f3aabbae942621e5fbe80430a23a0c8d77474b02 100644 (file)
@@ -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