1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: fix leak in rune.str(), fix leaks in most assert x == y statements in tests (#11091)

This commit is contained in:
Delyan Angelov
2021-08-13 18:37:34 +03:00
committed by GitHub
parent 0bd68bf5a2
commit 34d39ccb64
15 changed files with 152 additions and 22 deletions

View File

@@ -55,6 +55,23 @@ pub:
rvalue string // the stringified *actual value* of the right side of a failed assertion
}
// free is used to free the memory occupied by the assertion meta data.
// It is called by cb_assertion_failed, and cb_assertion_ok in the preludes,
// once they are done with reporting/formatting the meta data.
[manualfree; unsafe]
pub fn (ami &VAssertMetaInfo) free() {
unsafe {
ami.fpath.free()
ami.fn_name.free()
ami.src.free()
ami.op.free()
ami.llabel.free()
ami.rlabel.free()
ami.lvalue.free()
ami.rvalue.free()
}
}
fn __print_assert_failure(i &VAssertMetaInfo) {
eprintln('$i.fpath:${i.line_nr + 1}: FAIL: fn $i.fn_name: assert $i.src')
if i.op.len > 0 && i.op != 'call' {