mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: Fix undefined behaviour when allocating empty structs (#4088)
This commit is contained in:
@@ -177,6 +177,9 @@ pub fn free(ptr voidptr) {
|
||||
}
|
||||
|
||||
pub fn memdup(src voidptr, sz int) voidptr {
|
||||
if sz == 0 {
|
||||
return vcalloc(1)
|
||||
}
|
||||
mem := malloc(sz)
|
||||
return C.memcpy(mem, src, sz)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user