dasm-assembler / dasm

Macro assembler with support for several 8-bit microprocessors
https://dasm-assembler.github.io/
GNU General Public License v2.0
215 stars 40 forks source link

SEGV in error handling of command line parameters #128

Open srowe opened 2 years ago

srowe commented 2 years ago

Trying to define a macro on the command line as follows:

dasm firmware.asm -ofirmware.bin -DFW_VERSION=1.aa -f3 -S -sfirmware.sym

results in:

Program received signal SIGSEGV, Segmentation fault.
asmerr (err=6, bAbort=false, sText=0x7fffffffddf4 "1.aa") at main.c:1578
1578    main.c: No such file or directory.
(gdb) where
#0  asmerr (err=6, bAbort=false, sText=0x7fffffffddf4 "1.aa") at main.c:1578
#1  0x0000000000409fac in eval (str=0x7fffffffddf8 "", wantmode=0) at exp.c:575
#2  0x0000000000407dca in v_set (str=0x7fffffffddf4 "1.aa", dummy=0x0) at ops.c:1232
#3  0x0000000000401fa8 in MainShadow (ac=7, av=0x7fffffffd948, pbTableSort=0x7fffffffd84b) at main.c:490
#4  0x0000000000404cde in main (ac=7, av=0x7fffffffd948) at main.c:1747

This seems to be as a result of bStopAtEnd being NULL

(gdb) print err
$1 = 6
(gdb) print bStopAtEnd
$2 = (_Bool *) 0x0

it is malloc()after command line arguments are processed.