diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2019-10-08 15:30:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-08 15:30:50 (GMT) |
commit | 10cd00a9e3c22af37c748ea5a417f6fb66601e21 (patch) | |
tree | b1f56966388b990f6ac7838f1435ae48ad5c7409 /Misc/NEWS.d/next/C API | |
parent | 03ab6b4fc6f59a4452756e7a3a46310ce30ec4b2 (diff) | |
download | cpython-10cd00a9e3c22af37c748ea5a417f6fb66601e21.zip cpython-10cd00a9e3c22af37c748ea5a417f6fb66601e21.tar.gz cpython-10cd00a9e3c22af37c748ea5a417f6fb66601e21.tar.bz2 |
bpo-38395: Fix ownership in weakref.proxy methods (GH-16632)
The implementation of weakref.proxy's methods call back into the Python
API using a borrowed references of the weakly referenced object
(acquired via PyWeakref_GET_OBJECT). This API call may delete the last
reference to the object (either directly or via GC), leaving a dangling
pointer, which can be subsequently dereferenced.
To fix this, claim a temporary ownership of the referenced object when
calling the appropriate method. Some functions because at the moment they
do not need to access the borrowed referent, but to protect against
future changes to these functions, ownership need to be fixed in
all potentially affected methods.
Diffstat (limited to 'Misc/NEWS.d/next/C API')
-rw-r--r-- | Misc/NEWS.d/next/C API/2019-10-08-01-23-24.bpo-38395.MJ6Ey9.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/C API/2019-10-08-01-23-24.bpo-38395.MJ6Ey9.rst b/Misc/NEWS.d/next/C API/2019-10-08-01-23-24.bpo-38395.MJ6Ey9.rst new file mode 100644 index 0000000..4bc3060 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2019-10-08-01-23-24.bpo-38395.MJ6Ey9.rst @@ -0,0 +1,3 @@ +Fix a crash in :class:`weakref.proxy` objects due to incorrect lifetime +management when calling some associated methods that may delete the last +reference to object being referenced by the proxy. Patch by Pablo Galindo. |