hare

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

commit 61e879b522a5017005d53d4bf2409d1c41cd6dc1
parent 74138f7c068c675feee42967151085089c41c62a
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 11 May 2022 14:57:08 +0200

encoding::json: fix double free

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mencoding/json/lex.ha | 2++
Mencoding/json/load.ha | 3++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/encoding/json/lex.ha b/encoding/json/lex.ha @@ -103,6 +103,7 @@ fn unlex(lex: *lexer, tok: token) void = { // resulting word. fn scan_word(lex: *lexer) (str | error) = { strio::reset(&lex.strbuf); + for (true) { const rn = match (nextrune(lex)?) { case let rn: rune => @@ -116,6 +117,7 @@ fn scan_word(lex: *lexer) (str | error) = { }; strio::appendrune(&lex.strbuf, rn)!; }; + return strio::string(&lex.strbuf); }; diff --git a/encoding/json/load.ha b/encoding/json/load.ha @@ -25,7 +25,7 @@ fn _load(lexer: *lexer) (value | error) = { case let f: f64 => return f; case let s: str => - return s; + return strings::dup(s); case arraystart => return _load_array(lexer); case objstart => @@ -76,6 +76,7 @@ fn _load_obj(lexer: *lexer) (value | error) = { }; const val = _load(lexer)?; + defer finish(val); set(&obj, key, val); tok = mustscan(lexer)?;