mirror of
https://github.com/python/cpython.git
synced 2025-09-30 12:21:51 +00:00
bpo-29438: fixed use-after-free in key sharing dict (#39)
This commit is contained in:
parent
f66c81ff49
commit
89ddffbe9d
2 changed files with 9 additions and 3 deletions
|
@ -10,6 +10,8 @@ What's New in Python 3.6.1 release candidate 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- bpo-29438: Fixed use-after-free problem in key sharing dict.
|
||||||
|
|
||||||
- Issue #29319: Prevent RunMainFromImporter overwriting sys.path[0].
|
- Issue #29319: Prevent RunMainFromImporter overwriting sys.path[0].
|
||||||
|
|
||||||
- Issue #29337: Fixed possible BytesWarning when compare the code objects.
|
- Issue #29337: Fixed possible BytesWarning when compare the code objects.
|
||||||
|
|
|
@ -4376,15 +4376,19 @@ _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr,
|
||||||
}
|
}
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
res = PyDict_DelItem(dict, key);
|
res = PyDict_DelItem(dict, key);
|
||||||
if (cached != ((PyDictObject *)dict)->ma_keys) {
|
// Since key sharing dict doesn't allow deletion, PyDict_DelItem()
|
||||||
|
// always converts dict to combined form.
|
||||||
|
if ((cached = CACHED_KEYS(tp)) != NULL) {
|
||||||
CACHED_KEYS(tp) = NULL;
|
CACHED_KEYS(tp) = NULL;
|
||||||
DK_DECREF(cached);
|
DK_DECREF(cached);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int was_shared = cached == ((PyDictObject *)dict)->ma_keys;
|
int was_shared = (cached == ((PyDictObject *)dict)->ma_keys);
|
||||||
res = PyDict_SetItem(dict, key, value);
|
res = PyDict_SetItem(dict, key, value);
|
||||||
if (was_shared && cached != ((PyDictObject *)dict)->ma_keys) {
|
if (was_shared &&
|
||||||
|
(cached = CACHED_KEYS(tp)) != NULL &&
|
||||||
|
cached != ((PyDictObject *)dict)->ma_keys) {
|
||||||
/* PyDict_SetItem() may call dictresize and convert split table
|
/* PyDict_SetItem() may call dictresize and convert split table
|
||||||
* into combined table. In such case, convert it to split
|
* into combined table. In such case, convert it to split
|
||||||
* table again and update type's shared key only when this is
|
* table again and update type's shared key only when this is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue