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

ci: fix sanitizers and add -fsanitize=undefined (#7306)

This commit is contained in:
ka-weihe
2020-12-14 06:34:47 +01:00
committed by GitHub
parent 9b139c58ca
commit f57c7032b4
3 changed files with 24 additions and 6 deletions

View File

@@ -338,7 +338,9 @@ pub fn (a &array) clone() array {
unsafe {arr.set_unsafe(i, &ar_clone)}
}
} else {
unsafe {C.memcpy(byteptr(arr.data), a.data, a.cap * a.element_size)}
if !isnil(a.data) {
unsafe {C.memcpy(byteptr(arr.data), a.data, a.cap * a.element_size)}
}
}
return arr
}
@@ -396,7 +398,7 @@ fn (mut a array) push(val voidptr) {
// `val` is array.data
// TODO make private, right now it's used by strings.Builder
pub fn (mut a3 array) push_many(val voidptr, size int) {
if a3.data == val {
if a3.data == val && !isnil(a3.data) {
// handle `arr << arr`
copy := a3.clone()
a3.ensure_cap(a3.len + size)
@@ -406,7 +408,9 @@ pub fn (mut a3 array) push_many(val voidptr, size int) {
}
} else {
a3.ensure_cap(a3.len + size)
unsafe {C.memcpy(a3.get_unsafe(a3.len), val, a3.element_size * size)}
if !isnil(a3.data) && !isnil(val) {
unsafe {C.memcpy(a3.get_unsafe(a3.len), val, a3.element_size * size)}
}
}
a3.len += size
}