mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-31 18:20:22 +08:00
preproc: do_directive: Allocate 'Include' from zeroified-memory
If not all members of structure being allocated from heap get initialized we better to use nasm_zalloc instead of nasm_malloc. For example inc gets allocated in do_directive being parially initialized and we erroniously get mmac_depth set to some crappy value leading to SIGSEV in result. [ http://forum.nasm.us/index.php?topic=921.msg3257#msg3257 ] nb: I've cleaned verror from tab/space mess while were at it Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
5fa1b1f47a
commit
55cc4d0423
26
preproc.c
26
preproc.c
@ -2601,7 +2601,7 @@ static int do_directive(Token * tline)
|
||||
p = t->text;
|
||||
if (t->type != TOK_INTERNAL_STRING)
|
||||
nasm_unquote_cstr(p, i);
|
||||
inc = nasm_malloc(sizeof(Include));
|
||||
inc = nasm_zalloc(sizeof(Include));
|
||||
inc->next = istk;
|
||||
inc->fp = inc_fopen(p, dephead, &deptail, pass == 0);
|
||||
if (!inc->fp) {
|
||||
@ -5019,21 +5019,19 @@ static void verror(int severity, const char *fmt, va_list arg)
|
||||
|
||||
vsnprintf(buff, sizeof(buff), fmt, arg);
|
||||
|
||||
if ((istk != NULL) && (istk->mmac_depth > 0)) {
|
||||
ExpInv *ei = istk->expansion;
|
||||
int lineno = ei->lineno;
|
||||
while (ei != NULL) {
|
||||
if (ei->type == EXP_MMACRO) {
|
||||
break;
|
||||
}
|
||||
lineno += ei->relno;
|
||||
ei = ei->prev;
|
||||
}
|
||||
if (istk && istk->mmac_depth > 0) {
|
||||
ExpInv *ei = istk->expansion;
|
||||
int lineno = ei->lineno;
|
||||
while (ei) {
|
||||
if (ei->type == EXP_MMACRO)
|
||||
break;
|
||||
lineno += ei->relno;
|
||||
ei = ei->prev;
|
||||
}
|
||||
nasm_error(severity, "(%s:%d) %s", ei->def->name,
|
||||
lineno, buff);
|
||||
} else {
|
||||
lineno, buff);
|
||||
} else
|
||||
nasm_error(severity, "%s", buff);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user