From 21c65e8f33c2b190c3612509b24046f75c478403 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9my=20Oudompheng?= Date: Fri, 27 Jan 2012 09:36:53 +0100 Subject: [PATCH] cgo: accept null pointers in gccgo flavour of C.GoString. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5569074 --- src/cmd/cgo/out.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 3e25b2099c..2c01074991 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -786,7 +786,8 @@ const char *CString(struct __go_string s) { } struct __go_string GoString(char *p) { - return __go_byte_array_to_string(p, strlen(p)); + int len = (p != NULL) ? strlen(p) : 0; + return __go_byte_array_to_string(p, len); } struct __go_string GoStringN(char *p, int n) { -- 2.50.0