mirror of
https://github.com/fachat/xa65.git
synced 2025-02-11 06:30:33 +00:00
Fix memory corruption as of issue #2
This commit is contained in:
parent
3ce489442c
commit
7e71d01a9a
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LD = gcc
|
LD = gcc
|
||||||
CFLAGS = -O2 -W -Wall -pedantic -ansi
|
CFLAGS = -O2 -W -Wall -pedantic -std=c99 -g
|
||||||
LDFLAGS = -lc
|
LDFLAGS = -lc
|
||||||
|
|
||||||
# for DOS?
|
# 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 */
|
/* stub for handling CPP directives */
|
||||||
int pp_cpp(char *t) {
|
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 */
|
/* massage it into our parameters and drop last quote */
|
||||||
char *u = "";
|
char *u = "";
|
||||||
|
|
||||||
filep->fline--;
|
filep->fline--;
|
||||||
if((u = (char *)strrchr(filep->fname, '"')))
|
if((u = (char *)strrchr(fname, '"')))
|
||||||
*u = '\0';
|
*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);
|
return (0);
|
||||||
} else {
|
} else {
|
||||||
return(E_SYNTAX);
|
return(E_SYNTAX);
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
# 1 "over.c"
|
# 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
|
lda #1
|
||||||
jmp buggy
|
jmp buggy
|
||||||
rts
|
rts
|
||||||
@ -26,7 +19,4 @@ fuzz lda #5
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
lda @$c0c0c0
|
lda @$c0c0c0
|
||||||
# 17 "over.c" 2
|
# 18 "over.c" 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user