mirror of
https://github.com/fachat/xa65.git
synced 2025-02-06 03:29:58 +00:00
Fix memory corruption as of issue #2
This commit is contained in:
parent
3ce489442c
commit
7e71d01a9a
@ -2,7 +2,7 @@
|
||||
#
|
||||
CC = gcc
|
||||
LD = gcc
|
||||
CFLAGS = -O2 -W -Wall -pedantic -ansi
|
||||
CFLAGS = -O2 -W -Wall -pedantic -std=c99 -g
|
||||
LDFLAGS = -lc
|
||||
|
||||
# for DOS?
|
||||
|
11
xa/src/xap.c
11
xa/src/xap.c
@ -214,13 +214,20 @@ int pp_endif(char *t)
|
||||
/* stub for handling CPP directives */
|
||||
int pp_cpp(char *t) {
|
||||
|
||||
if(sscanf(t, " %d \"%s\"", &filep->fline, filep->fname) == 2) {
|
||||
char *fname = NULL;
|
||||
if(sscanf(t, " %d \"%ms\"", &filep->fline, &fname) == 2) {
|
||||
/* massage it into our parameters and drop last quote */
|
||||
char *u = "";
|
||||
|
||||
filep->fline--;
|
||||
if((u = (char *)strrchr(filep->fname, '"')))
|
||||
if((u = (char *)strrchr(fname, '"')))
|
||||
*u = '\0';
|
||||
|
||||
// overwrite the original filename
|
||||
// this may create a memory leak, but we do not know
|
||||
// whether the file name has already been used in the cross
|
||||
// reference list. So we just accept that...
|
||||
filep->fname = fname;
|
||||
return (0);
|
||||
} else {
|
||||
return(E_SYNTAX);
|
||||
|
@ -1,16 +1,9 @@
|
||||
# 1 "over.c"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 1 "<command-line>"
|
||||
# 1 "/usr/include/stdc-predef.h" 1 3 4
|
||||
# 1 "<command-line>" 2
|
||||
# 1 "over.c"
|
||||
# 13 "over.c"
|
||||
lda #1
|
||||
jmp buggy
|
||||
rts
|
||||
@ -26,7 +19,4 @@ fuzz lda #5
|
||||
rts
|
||||
|
||||
lda @$c0c0c0
|
||||
# 17 "over.c" 2
|
||||
|
||||
|
||||
|
||||
# 18 "over.c" 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user