aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-09-16 14:04:55 -0400
committerRuss Cox <rsc@golang.org>2013-09-16 14:04:55 -0400
commit647eaed93b2aba07d4d4d032d5f58bf6dbc06e5a (patch)
treee2cbd94e66668dea4773f4edb2f5cddeb154035e /src/pkg
parentb2794a1c2ed8c74563cf28d9e4a9b3f1db43ef1f (diff)
downloadgo-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')
-rw-r--r--src/pkg/runtime/cgo/gcc_util.c2
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 */