Commit bbc47fbb authored by Alex Brainman's avatar Alex Brainman

windows/registry: mark string end with 0 before calling Windows ExpandEnvironmentStrings

Change-Id: I02bfcdeac44167d1dbeb15bcd5c82111fba3f527
Reviewed-on: https://go-review.googlesource.com/9234Reviewed-by: 's avatarRob Pike <r@golang.org>
parent e9616980
......@@ -119,15 +119,13 @@ func ExpandString(value string) (string, error) {
if value == "" {
return "", nil
}
for i := 0; i < len(value); i++ {
if value[i] == 0 {
return "", errors.New("string cannot have 0 inside")
}
p, err := syscall.UTF16PtrFromString(value)
if err != nil {
return "", err
}
p := utf16.Encode([]rune(value))
r := make([]uint16, 100)
for {
n, err := expandEnvironmentStrings(&p[0], &r[0], uint32(len(r)))
n, err := expandEnvironmentStrings(p, &r[0], uint32(len(r)))
if err != nil {
return "", err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment