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 | 1b7392444183c40afb85b6e20aa5f3b4a2112f27 (patch) | |
tree | 48e0c43b51192fd5dd9cebd014f6c5d530cdc33b /src/runtime/cgocallback.go | |
parent | 70df1111b1bdba591f02e6ca0628a0a73c6427d6 (diff) | |
download | go-1b7392444183c40afb85b6e20aa5f3b4a2112f27.tar.gz |
runtime: fix _cgo_allocate(0)
Fixes a SWIG bug reported off-list.
LGTM=iant
R=iant
CC=golang-codereviews
https://codereview.appspot.com/155990043
Diffstat (limited to 'src/runtime/cgocallback.go')
-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 1e1b57607..2c8914320 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 |