]> Cypherpunks repositories - gostls13.git/commitdiff
os: use small buffer when reading from windows console
authorAlex Brainman <alex.brainman@gmail.com>
Thu, 16 May 2013 07:20:13 +0000 (17:20 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Thu, 16 May 2013 07:20:13 +0000 (17:20 +1000)
Fixes #5481.

R=golang-dev, dominik.honnef, bradfitz
CC=golang-dev
https://golang.org/cl/9437044

src/pkg/os/file_windows.go

index 82af756d89f6bace4dcf58e62ba4b07fcd32d5b1..41233fff64bcfa88a4cb7c7430a941f6e332f9d8 100644 (file)
@@ -251,8 +251,14 @@ func (f *File) readConsole(b []byte) (n int, err error) {
                return 0, nil
        }
        if len(f.readbuf) == 0 {
+               // syscall.ReadConsole seems to fail, if given large buffer.
+               // So limit the buffer to 16000 characters.
+               readN := 16000
+               if len(b) < readN {
+                       readN = len(b)
+               }
                // get more input data from os
-               wchars := make([]uint16, len(b))
+               wchars := make([]uint16, readN)
                var p *uint16
                if len(b) > 0 {
                        p = &wchars[0]