From: Ian Lance Taylor Date: Sat, 6 Jul 2024 21:42:16 +0000 (-0700) Subject: unsafe: clarify when String bytes can be modified X-Git-Tag: go1.23rc2~2^2~17 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6d89b38ed86e0bfa0ddaba08dc4071e6bb300eea;p=gostls13.git unsafe: clarify when String bytes can be modified They can be modified when the string returned by String no longer exists. Fixes #68300 Change-Id: I526a068151f7aad1ab6827504b51a84e7399cafe Reviewed-on: https://go-review.googlesource.com/c/go/+/596955 Reviewed-by: Keith Randall Reviewed-by: Keith Randall Reviewed-by: Than McIntosh Commit-Queue: Ian Lance Taylor Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI --- diff --git a/src/unsafe/unsafe.go b/src/unsafe/unsafe.go index 8d6cacb8b5..645ddf2c8a 100644 --- a/src/unsafe/unsafe.go +++ b/src/unsafe/unsafe.go @@ -260,7 +260,7 @@ func SliceData(slice []ArbitraryType) *ArbitraryType // a run-time panic occurs. // // Since Go strings are immutable, the bytes passed to String -// must not be modified afterwards. +// must not be modified as long as the returned string value exists. func String(ptr *byte, len IntegerType) string // StringData returns a pointer to the underlying bytes of str.