File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 44 "cmp"
55 "strings"
66 "unicode"
7+ "unsafe"
78
89 "github.com/microsoft/typescript-go/internal/stringutil"
910)
@@ -606,7 +607,12 @@ func ToFileNameLowerCase(fileName string) string {
606607 }
607608 b [i ] = c
608609 }
609- return string (b )
610+ // SAFETY: `b` is a freshly allocated, non-empty byte slice whose contents are
611+ // fully initialized. We do not mutate `b` after this point, and the returned
612+ // string becomes the only live reference to its backing array. The array is
613+ // heap-allocated (via make), so the GC keeps it alive for the lifetime of the
614+ // returned string. Since len(b) > 0 here, &b[0] is a valid pointer.
615+ return unsafe .String (& b [0 ], len (b ))
610616 }
611617
612618 return strings .Map (func (r rune ) rune {
You can’t perform that action at this time.
0 commit comments