From aa5d316816e43bb3614d2b9808a998c089222ab0 Mon Sep 17 00:00:00 2001 From: saxon Date: Sun, 13 Jan 2019 19:15:02 +1030 Subject: [PATCH 1/2] revid: made revid.Config() return copy of revid's config rather than pointer so that mutation isn't possible --- revid/revid.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index 409ba702..ef8da970 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -181,13 +181,8 @@ func (r *Revid) Bitrate() int { } // Config returns the Revid's config. -func (r *Revid) Config() *Config { - // FIXME(kortschak): This is a massive footgun and should not exist. - // Since the config's fields are accessed in running goroutines, any - // mutation is a data race. With bad luck a data race is possible by - // reading the returned value since it is possible for the running - // Ravid to mutate the config it holds. - return &r.config +func (r *Revid) Config() Config { + return r.config } // reset swaps the current config of a Revid with the passed From ba54974de9c37b68d446dbaa53de9ea01a1eee1a Mon Sep 17 00:00:00 2001 From: saxon Date: Sun, 13 Jan 2019 21:50:47 +1030 Subject: [PATCH 2/2] revid: removed Config() func from revid because it's not being used --- revid/revid.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index ef8da970..6205a04a 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -180,11 +180,6 @@ func (r *Revid) Bitrate() int { return r.bitrate } -// Config returns the Revid's config. -func (r *Revid) Config() Config { - return r.config -} - // reset swaps the current config of a Revid with the passed // configuration; checking validity and returning errors if not valid. func (r *Revid) reset(config Config) error {