]> Cypherpunks repositories - gostls13.git/commit
cmd/cgo: fix C.CString for strings containing null terminators under gccgo
authorPeter Collingbourne <pcc@google.com>
Sun, 27 Apr 2014 05:16:38 +0000 (22:16 -0700)
committerIan Lance Taylor <iant@golang.org>
Sun, 27 Apr 2014 05:16:38 +0000 (22:16 -0700)
commit8cb916f71d7d397905b9d8a5a0ea5c22871ac867
treedbfe0ae18b396dcb268218abddedd6f1f79f2616
parent9f2e1efd725036c2d71a5d5df39ffe42b12e9383
cmd/cgo: fix C.CString for strings containing null terminators under gccgo

Previously we used strndup(3) to implement C.CString for gccgo. This
is wrong because strndup assumes the string to be null terminated,
and stops at the first null terminator. Instead, use malloc
and memmove to create a copy of the string, as we do in the
gc implementation.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/96790047
src/cmd/cgo/out.go