From fda7caef9386a315a56a498ac96d3fae0d946fae Mon Sep 17 00:00:00 2001 From: Henrixounez <30901439+Henrixounez@users.noreply.github.com> Date: Thu, 27 Jun 2019 12:14:33 +0200 Subject: [PATCH] os.v: getline fixed conditional jump on uninitialized values --- os/os.v | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/os/os.v b/os/os.v index 61ab53e0a9..241b2fe6aa 100644 --- a/os/os.v +++ b/os/os.v @@ -408,9 +408,12 @@ pub fn filename(path string) string { } // get_line returns a one-line string from stdin +//u64 is used because C.getline needs a size_t as second argument +//Otherwise, it would cause a valgrind warning and may be dangerous +//Malloc takes an int as argument so a cast has to be made pub fn get_line() string { - max := 256 - buf := malloc(max) + max := u64(256) + buf := malloc(int(max)) nr_chars := C.getline(&buf, &max, stdin) if nr_chars == 0 { return ''