Skip to content

Commit

Permalink
fix: ensure to use correct pointer in home loop
Browse files Browse the repository at this point in the history
When dereferencing loop variables in go, one must ensure to copy the value
in the loop variable before dereferencing. Else one dereferences the
loop pointer instead of the variable. See [1] for more details.

[1]: https://stackoverflow.com/questions/45967305/copying-the-address-of-a-loop-variable-in-go
  • Loading branch information
gonzolino committed Dec 14, 2021
1 parent b0811d9 commit 45e09b8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions window-close.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func CloseWindow(w http.ResponseWriter, r *http.Request) {
var userHome *gotado.UserHome
for _, h := range user.Homes {
if h.Name == action.HomeName {
h := h
userHome = &h
break
}
Expand Down

0 comments on commit 45e09b8

Please sign in to comment.