hare

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

commit 2267e99b6271d132366ca1c128abc021a9954045
parent 95a0e5959caecfe41275a7ef84bbbf817c52c20d
Author: Byron Torres <b@torresjrjr.com>
Date:   Mon, 31 Jan 2022 16:05:20 +0000

fix olson::tz() open file leak

Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mtime/olson/olson.ha | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/time/olson/olson.ha b/time/olson/olson.ha @@ -1,3 +1,4 @@ +use bufio; use endian; use errors; use fs; @@ -43,7 +44,11 @@ export fn tz(name: str) (chrono::timezone | errors::overflow | fs::error | io::e path::add(&filepath, prefix, name)?; const fpath = path::string(&filepath); const file = os::open(fpath)?; - const tz = parse_tzif(file, chrono::timezone { + defer io::close(file); + + static let buf: [os::BUFSIZ]u8 = [0...]; + const file = bufio::buffered(file, buf, []); + const tz = parse_tzif(&file, chrono::timezone { name = name, timescale = &chrono::utc, daylength = chrono::EARTH_DAY,