Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lock before changing field of backends (#843)
* Lock before changing field of backends The `SetBackend` method updates one of the members of the package-level variable `backends`. Since it's a pointer, it's probably safe on most architectures. But the `Backends` struct already has a `sync.RWMutex` field, and earlier in the file the `GetBackend` function goes through the trouble of explicitly acquiring a read and possibly a write lock. See: https://github.com/stripe/stripe-go/blob/d94ce0ed857fb1571b9b30bd24430bdac3d50c0f/stripe.go#L666 So to be safe, and consistent with the rest of the code, it makes sense to acquire a write lock before updating the `backends` value.
- Loading branch information