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

parser,gen: fix `arr << map[key] using map_get_and_set_1, leading to double free

This commit is contained in:
Delyan Angelov
2021-02-16 15:08:01 +02:00
parent 982e35909d
commit 843de10442
6 changed files with 70 additions and 21 deletions

View File

@ -1092,7 +1092,9 @@ fn test_push_arr_string_free() {
mut lines := ['hi']
s := 'a' + 'b'
lines << s
s.free() // make sure the data in the array is valid after freeing the string
// make sure the data in the array is valid after freeing the string
unsafe { s.free() }
//
println(lines)
assert lines.len == 2
assert lines[0] == 'hi'