Package: as31
Version: 2.3.1-4
Severity: normal
Tags: patch

At the end of the input file, as31 acts as if the last line is
repeated.  For example:

  $ printf "one:\ntwo:\nthree:\n" > test.asm
  $ as31 test.asm
  Begin Pass #1
  incLineCount=0
  Warning, line 4, Attempt to redefine symbol: three.
  Errors in pass1, assembly aborted
  Errors in pass2, assembly aborted

If the last line is an instruction, the opcode will get repeated in
the hex file.

Turns out this is due to a bug in the include parsing.  Patch
attached.

-jim

-- System Information:
Debian Release: 6.0.3
  APT prefers stable
  APT policy: (200, 'stable'), (150, 'oldstable'), (80, 'testing'), (50, 
'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.37-trunk-amd64 (SMP w/4 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages as31 depends on:
ii  libc6  2.11.2-10

as31 recommends no packages.

as31 suggests no packages.

-- no debconf information
--- as31-2.3.1-orig/as31/run.c  2012-01-11 19:29:35.000000000 -0500
+++ as31-2.3.1/as31/run.c       2012-01-11 19:31:56.000000000 -0500
@@ -106,7 +106,8 @@
        }
 
        while (!feof(finPre)) {
-               getline(&lineBuffer,&sizeBuf,finPre);
+               if (getline(&lineBuffer,&sizeBuf,finPre) == -1)
+                       break;
                if ((includePtr=strstr(lineBuffer,INC_CMD))) {
                        includePtr=includePtr+strlen(INC_CMD);
                        while ((*includePtr==' ')||             //move 
includePtr to filename
@@ -131,7 +132,8 @@
                                mesg_f("Cannot open include file: 
%s\n",includePtr);
                        } else {
                                while (!feof(includeFile)) {
-                                       
getline(&incLineBuffer,&incSizeBuf,includeFile);
+                                       if 
(getline(&incLineBuffer,&incSizeBuf,includeFile) == -1)
+                                               break;
                                        fprintf(fin,"%s",incLineBuffer);
                                        if (strlen(incLineBuffer)) {
                                                incLineCount++;

Reply via email to