hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 2f357d551b3e8b40587b8eabb98de3cfb8fa7192
parent 25a872c58fcf7cdc6fdeab4537b4bef1c122e4d6
Author: Alexey Yerin <yyp@disroot.org>
Date:   Wed, 27 Sep 2023 17:07:58 +0300

cmd/haredoc: Duplicate the static value of lex::tokstr

This causes an invalid free with e.g. 'haredoc insert::'.

Signed-off-by: Alexey Yerin <yyp@disroot.org>

Diffstat:
Mcmd/haredoc/main.ha | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/haredoc/main.ha b/cmd/haredoc/main.ha @@ -222,7 +222,7 @@ fn parseident(in: str) (ast::ident | parse::error) = { const name = if (tok.0 == lex::ltok::NAME) { yield tok.1 as str; } else if (tok.0 < lex::ltok::LAST_KEYWORD) { - yield lex::tokstr(tok); + yield strings::dup(lex::tokstr(tok)); } else { lex::unlex(&lexer, tok); const loc = lex::mkloc(&lexer);