hare

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

commit efc309916b8cc1d84f165dfc4011af532948b6e4
parent 797aa948a5667d6458fb6ce0c78f48e05045e43c
Author: Alexey Yerin <yyp@disroot.org>
Date:   Sun,  9 May 2021 19:46:30 +0300

hare::module: fix bufio::scanline leak

Byte array returned by scanline should be freed by the caller. It was
the case but not always because of early return.

Diffstat:
Mhare/module/manifest.ha | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha @@ -70,14 +70,16 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { for (true) { let line = match (bufio::scanline(file)?) { io::EOF => break, - line: []u8 => match (strings::try_fromutf8(line)) { - // Treat an invalid manifest as empty - utf8::invalid => return manifest, - s: str => s, - }, + line: []u8 => line, }; defer free(line); + let line = match (strings::try_fromutf8(line)) { + // Treat an invalid manifest as empty + utf8::invalid => return manifest, + s: str => s, + }; + if (strings::has_prefix(line, "#")) { continue; };