os: fix a leak in read_lines()

pull/9425/head
Alexander Medvednikov 2021-03-22 12:20:55 +03:00
parent 57b30507fa
commit a53aaaf9e7
1 changed files with 3 additions and 1 deletions

View File

@ -80,7 +80,9 @@ pub fn mv_by_cp(source string, target string) ? {
// read_lines reads the file in `path` into an array of lines.
pub fn read_lines(path string) ?[]string {
buf := read_file(path) ?
return buf.split_into_lines()
res := buf.split_into_lines()
unsafe { buf.free() }
return res
}
// read_ulines reads the file in `path` into an array of ustring lines.