Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
golang/go#40701: avoid comp lit usage of reflect.{String,Slice}Header
See golang/go#40701 example three.
- Loading branch information
610077f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this may not be problematic; the third example is more about how the function takes
(*byte, int)
and converts that to a slice. The compiler cannot detect that the new slice is escaping.Consider the input:
this would be invalid (if
c
were the example 3 func).However, to be even more super safe, may as well update to avoid dereffing the header at all.
610077f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears this change was still necessary, as without this change, this is the unsafe pattern 1 as documented in https://github.com/jlauinger/go-safer.