summaryrefslogtreecommitdiff
path: root/preproc.c
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2010-11-11 13:44:51 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2010-11-11 22:44:30 +0300
commit574fbf1972935e1d3199cf5ea7efe796fae5d29c (patch)
tree7f5d7e0eaa846b346f6bc5952aa90287910a1dd2 /preproc.c
parenta22e7a983c30d9822fd20145d1d4cd098df0909d (diff)
downloadnasm-574fbf1972935e1d3199cf5ea7efe796fae5d29c.tar.gz
nasm-574fbf1972935e1d3199cf5ea7efe796fae5d29c.tar.bz2
nasm-574fbf1972935e1d3199cf5ea7efe796fae5d29c.zip
preproc: Use nasm_zalloc more
To eliminate possible access into heap data Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'preproc.c')
-rw-r--r--preproc.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/preproc.c b/preproc.c
index 642c54f..4abddbf 100644
--- a/preproc.c
+++ b/preproc.c
@@ -2117,7 +2117,7 @@ static bool define_smacro(Context *ctx, const char *mname, bool casesense,
} else {
smtbl = ctx ? &ctx->localmac : &smacros;
smhead = (SMacro **) hash_findi_add(smtbl, mname);
- smac = nasm_malloc(sizeof(SMacro));
+ smac = nasm_zalloc(sizeof(SMacro));
smac->next = *smhead;
*smhead = smac;
}
@@ -2637,7 +2637,7 @@ static int do_directive(Token * tline)
}
if (i == PP_PUSH) {
- ctx = nasm_malloc(sizeof(Context));
+ ctx = nasm_zalloc(sizeof(Context));
ctx->next = cstk;
hash_init(&ctx->localmac, HASH_SMALL);
ctx->name = p;
@@ -2873,11 +2873,9 @@ issue_error:
eed = (ExpDef *) hash_findix(&expdefs, ed->name);
while (eed) {
- if (!strcmp(eed->name, ed->name) &&
- (eed->nparam_min <= ed->nparam_max
- || ed->plus)
- && (ed->nparam_min <= eed->nparam_max
- || eed->plus)) {
+ if (!strcmp(eed->name, ed->name) &&
+ (eed->nparam_min <= ed->nparam_max || ed->plus) &&
+ (ed->nparam_min <= eed->nparam_max || eed->plus)) {
error(ERR_WARNING|ERR_PASS1,
"redefining multi-line macro `%s'", ed->name);
return DIRECTIVE_FOUND;