diff options
| author | Russ Cox <rsc@golang.org> | 2014-10-07 16:27:40 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-10-07 16:27:40 -0400 |
| commit | 685204747d39b4a5d111406389f7a63bc34c7287 (patch) | |
| tree | ad8b244fd25d401d6153ef8ed4ae8b1a736c1c18 /src/runtime | |
| parent | 87f51f103181e47c78a5c3fd9a41d43fb707817b (diff) | |
| download | go-685204747d39b4a5d111406389f7a63bc34c7287.tar.xz | |
runtime: fix _cgo_allocate(0)
Fixes a SWIG bug reported off-list.
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/155990043
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/cgocallback.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/cgocallback.go b/src/runtime/cgocallback.go index 1e1b576072..2c89143208 100644 --- a/src/runtime/cgocallback.go +++ b/src/runtime/cgocallback.go @@ -21,6 +21,9 @@ import "unsafe" // Either we need to add types or we need to stop using it. func _cgo_allocate_internal(len uintptr) unsafe.Pointer { + if len == 0 { + len = 1 + } ret := unsafe.Pointer(&make([]unsafe.Pointer, (len+ptrSize-1)/ptrSize)[0]) c := new(cgomal) c.alloc = ret |
