compiler: avoid undefined behavior in Import::read
authorNikhil Benesch <nikhil.benesch@gmail.com>
Mon, 5 Oct 2020 03:40:40 +0000 (23:40 -0400)
committerIan Lance Taylor <iant@golang.org>
Tue, 6 Oct 2020 20:53:42 +0000 (13:53 -0700)
commitf5431aeaf5551995e1ec4455e33545bbc1170a1b
treeb86130cccc5ee6c5698061672064106be54aa590
parentfcae5121154d1c3382b056bcc2c563cedac28e74
compiler: avoid undefined behavior in Import::read

For some implementations of Stream, advancing the stream will invalidate
the previously-returned peek buffer. Copy the peek buffer before
advancing in Import::read to avoid this undefined behavior.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/259438
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/gogo.cc
gcc/go/gofrontend/import.cc
gcc/go/gofrontend/import.h