mirror of
https://github.com/affaan-m/ECC.git
synced 2026-12-01 04:05:39 +00:00
The sync.Pool example returned buf.Bytes(). That slice points into the pooled buffer. The deferred Reset and Put give the buffer to the next Get, so another goroutine can overwrite the result while the caller still uses it. Return bytes.Clone(buf.Bytes()) instead, and add a short note. Same code fix in the five translations. pi/core regenerated with scripts/build-pi-core.js. Tested: 64 goroutines calling the example under go test -race (Go 1.27). Old code: DATA RACE and wrong results. New code: passes. node scripts/build-pi-core.js --check passes. Replaces the golang part of closed PRs #3351 and #3405, which were not merged.