-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Two potential crashes here - one from the previous fix to #503, we would double-release a refcount on an object that was set for write. First we'd decrement the refcount when it was 'unbound', then again trying to unbind it for write because the slot wasn't NULL'd. This was just plain broken. * The second more obscure one was when binding for read. If the external object had no other refcount than the one in the binding slot, then changing its binding would implicitly destroy it. However if the code was setting the same object back again (ie. with the pointer they had not reference to) then the refcount would drop to 0 then should be incremented again to 1 when it's re-bound. However because the count bounces off 0, the object is destroyed between being unbound and re-bound causing pure virtual calls and other crashes when we try to access it. * The fix is first to check if we're binding something to its own slot and skip it. Second we need to keep the new objects ref'd at all times during the binding (in case we are e.g. performing an array bind which moves the 1-refcount object from slot 2 to slot 3. It would be unbound when processing slot 2, hit refcount 0, and then be added again when processing slot 3).
- Loading branch information
Showing
1 changed file
with
60 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters