handle zero sized allocs

This commit is contained in:
Jan Mercl
2021-01-12 17:40:04 +01:00
parent 9383707da0
commit 663f19b57d
3 changed files with 7 additions and 7 deletions

View File

@@ -1138,7 +1138,7 @@ func (c *conn) openV2(name string, flags int32) (uintptr, error) {
}
func (c *conn) malloc(n int) (uintptr, error) {
if p := libc.Xmalloc(c.tls, types.Size_t(n)); p != 0 {
if p := libc.Xmalloc(c.tls, types.Size_t(n)); p != 0 || n == 0 {
return p, nil
}