Skip to content

Commit

Permalink
Merge pull request #55 from guptarohit/fix-input-data-slice-update
Browse files Browse the repository at this point in the history
Fix unintended modification of input data slice
  • Loading branch information
guptarohit authored Aug 11, 2024
2 parents 956e426 + eabe3ca commit afd5937
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions asciigraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ func PlotMany(data [][]float64, options ...Option) string {
Precision: 2,
}, options)

// Create a deep copy of the input data
dataCopy := make([][]float64, len(data))
for i, series := range data {
dataCopy[i] = make([]float64, len(series))
copy(dataCopy[i], series)
}
data = dataCopy

lenMax := 0
for i := range data {
if l := len(data[i]); l > lenMax {
Expand Down

0 comments on commit afd5937

Please sign in to comment.