projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4ec7a63
)
macro: Fix memory leak with keyword "enclose" arguments.
author
Ben Pfaff
<blp@cs.stanford.edu>
Sat, 9 Oct 2021 16:23:52 +0000
(09:23 -0700)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Sat, 9 Oct 2021 16:23:52 +0000
(09:23 -0700)
The memory for the argument was being allocated two places, which caused
the first-allocated block to be leaked.
Found by Address Sanitizer.
src/language/lexer/macro.c
patch
|
blob
|
history
diff --git
a/src/language/lexer/macro.c
b/src/language/lexer/macro.c
index 814740bfac4e29bea9dc1365864c725034acbad0..62d060aad2ce21bc6320c0f05960f46051993cd4 100644
(file)
--- a/
src/language/lexer/macro.c
+++ b/
src/language/lexer/macro.c
@@
-707,7
+707,8
@@
mc_enclose (struct macro_call *mc, const struct macro_token *mt,
mc->n_tokens++;
struct macro_tokens **argp = &mc->args[p - mc->macro->params];
- *argp = xzalloc (sizeof **argp);
+ if (!*argp)
+ *argp = xzalloc (sizeof **argp);
mc->state = MC_ARG;
return 0;
}