]> Cypherpunks repositories - gostls13.git/commitdiff
cgo: accept null pointers in gccgo flavour of C.GoString.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 27 Jan 2012 08:36:53 +0000 (09:36 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 27 Jan 2012 08:36:53 +0000 (09:36 +0100)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5569074

src/cmd/cgo/out.go

index 3e25b2099c25e02d5b3eca5d5833dcb1816679ca..2c01074991050d38bff5b8487e8a288ffb9c8eaf 100644 (file)
@@ -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) {