aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2024-08-23 01:37:26 +0900
committerGitHub <noreply@github.com>2024-08-23 01:37:26 +0900
commit6cd67e413b9a6c5c81466c4e516bca6430d7297e (patch)
tree45d2fb6df2aad68de6acfc560a8ce1d44d9fa9df /Objects
parent[3.13] gh-123142: Fix too wide source locations in tracebacks of exceptions f... (diff)
downloadcpython-6cd67e413b9a6c5c81466c4e516bca6430d7297e.tar.gz
cpython-6cd67e413b9a6c5c81466c4e516bca6430d7297e.tar.bz2
cpython-6cd67e413b9a6c5c81466c4e516bca6430d7297e.zip
[3.13] gh-123083: Fix a potential use-after-free in ``STORE_ATTR_WITH… (#123235)
[3.13] gh-123083: Fix a potential use-after-free in ``STORE_ATTR_WITH_HINT`` (gh-123092) (cherry picked from commit 297f2e093ec95800ae2184330b8408c875523467)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 05600772db7..6586e0c5c27 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1762,6 +1762,8 @@ insert_split_value(PyInterpreterState *interp, PyDictObject *mp, PyObject *key,
uint64_t new_version = _PyDict_NotifyEvent(interp, PyDict_EVENT_MODIFIED, mp, key, value);
STORE_SPLIT_VALUE(mp, ix, Py_NewRef(value));
mp->ma_version_tag = new_version;
+ // old_value should be DECREFed after GC track checking is done, if not, it could raise a segmentation fault,
+ // when dict only holds the strong reference to value in ep->me_value.
Py_DECREF(old_value);
}
ASSERT_CONSISTENT(mp);