Skip to content

Commit

Permalink
Fixes Non-Cloned Pointers, a great catch by the tests!
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdubs committed Jan 13, 2024
1 parent a1c26c6 commit c7fb811
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pacta/pacta.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ type PortfolioProperties struct {
func (o PortfolioProperties) Clone() PortfolioProperties {
return PortfolioProperties{
HoldingsDate: o.HoldingsDate.Clone(),
ESG: o.ESG,
External: o.External,
EngagementStrategy: o.EngagementStrategy,
ESG: clonePtr(o.ESG),
External: clonePtr(o.External),
EngagementStrategy: clonePtr(o.EngagementStrategy),
}
}

Expand Down Expand Up @@ -776,3 +776,11 @@ func cloneAll[T cloneable[T]](in []T) []T {
}
return out
}

func clonePtr[T any](in *T) *T {
if in == nil {
return nil
}
out := *in
return &out
}

0 comments on commit c7fb811

Please sign in to comment.