From: Rémy Oudompheng Date: Fri, 27 Jan 2012 08:36:53 +0000 (+0100) Subject: cgo: accept null pointers in gccgo flavour of C.GoString. X-Git-Tag: weekly.2012-02-07~253 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=21c65e8f33c2b190c3612509b24046f75c478403;p=gostls13.git cgo: accept null pointers in gccgo flavour of C.GoString. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5569074 --- 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) {