summaryrefslogtreecommitdiff
path: root/src/runtime/cgocallback.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-07 16:27:40 -0400
committerRuss Cox <rsc@golang.org>2014-10-07 16:27:40 -0400
commit685204747d39b4a5d111406389f7a63bc34c7287 (patch)
treead8b244fd25d401d6153ef8ed4ae8b1a736c1c18 /src/runtime/cgocallback.go
parent87f51f103181e47c78a5c3fd9a41d43fb707817b (diff)
downloadgo-git-685204747d39b4a5d111406389f7a63bc34c7287.tar.gz
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/cgocallback.go')
-rw-r--r--src/runtime/cgocallback.go3
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