Skip to content

Commit

Permalink
Prevent caller to modify underlying array
Browse files Browse the repository at this point in the history
  • Loading branch information
groggy7 authored and bounoable committed Sep 24, 2023
1 parent 875903b commit 36cb215
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/mongo/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ func (tx *transaction) EventStore() *EventStore {
func (tx *transaction) InsertedEvents() []event.Event {
tx.mux.RLock()
defer tx.mux.RUnlock()
return tx.insertedEvents

copiedEvents := make([]event.Event, len(tx.insertedEvents))
copy(copiedEvents, tx.insertedEvents)

return copiedEvents
}

func (tx *transaction) appendEvents(events []event.Event) {
Expand Down

0 comments on commit 36cb215

Please sign in to comment.