diff options
| author | Russ Cox <rsc@golang.org> | 2013-09-16 14:04:55 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2013-09-16 14:04:55 -0400 |
| commit | 647eaed93b2aba07d4d4d032d5f58bf6dbc06e5a (patch) | |
| tree | e2cbd94e66668dea4773f4edb2f5cddeb154035e /src/pkg/runtime/cgo | |
| parent | b2794a1c2ed8c74563cf28d9e4a9b3f1db43ef1f (diff) | |
| download | go-647eaed93b2aba07d4d4d032d5f58bf6dbc06e5a.tar.xz | |
cmd/cgo: allow C.malloc(0) always
Because we can, and because it otherwise might crash
the program if we think we're out of memory.
Fixes #6390.
R=golang-dev, iant, minux.ma
CC=golang-dev
https://golang.org/cl/13345048
Diffstat (limited to 'src/pkg/runtime/cgo')
| -rw-r--r-- | src/pkg/runtime/cgo/gcc_util.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/pkg/runtime/cgo/gcc_util.c b/src/pkg/runtime/cgo/gcc_util.c index 20913d7369..143734e94b 100644 --- a/src/pkg/runtime/cgo/gcc_util.c +++ b/src/pkg/runtime/cgo/gcc_util.c @@ -14,6 +14,8 @@ x_cgo_malloc(void *p) } *a = p; a->ret = malloc(a->n); + if(a->ret == NULL && a->n == 0) + a->ret = malloc(1); } /* Stub for calling free from Go */ |
