Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

🗞️ Only allocate pointers when we are ready to set/use the result #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

suhailpatel
Copy link
Member

@suhailpatel suhailpatel commented Jul 1, 2019

If you pass a pointer to an address that is nil, we do some allocation. Right now this happens at the top of the function so we didn't have to worry about it.

This PR changes that behaviour slightly to allocate right before we are ready to set (and after some errors have been handled). In gocassa v2.0.0, this behaviour was undefined but there are users who were relying on the result value/pointer being untouched (unallocated in the nil case) in the case of an error. Also adds a test to make sure we don't have a future regression.

@suhailpatel suhailpatel self-assigned this Jul 1, 2019
@suhailpatel suhailpatel requested a review from a team July 1, 2019 19:23
Copy link

@lyubent lyubent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

July 19, yikes.
LGTM.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants