8000 Don't immortalize user-provided attr names in _ctypes · python/cpython@f2d457e · GitHub
[go: up one dir, main page]

Skip to content

Commit f2d457e

Browse files
committed
< 8000 div class="Box-sc-g0xbh4-0 LoadingSkeleton-sc-695d630a-0 dNbsEP ihfxfT ml-2" width="62px">
Don't immortalize user-provided attr names in _ctypes
1 parent 0576943 commit f2d457e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,9 +2303,14 @@ PyCSimpleType_init(PyObject *self, PyObject *args, PyObject *kwds)
23032303
if (!meth) {
23042304
return -1;
23052305
}
2306-
x = PyDict_SetItemString(((PyTypeObject*)self)->tp_dict,
2307-
ml->ml_name,
2308-
meth);
2306+
PyObject *name = PyUnicode_FromString(ml->ml_name);
2307+
if (name == NULL) {
2308+
Py_DECREF(meth);
2309+
return -1;
2310+
}
2311+
PyUnicode_InternInPlace(&name);
2312+
x = PyDict_SetItem(((PyTypeObject*)self)->tp_dict, name, meth);
2313+
Py_DECREF(name);
23092314
Py_DECREF(meth);
23102315
if (x == -1) {
23112316
return -1;

0 commit comments

Comments
 (0)
0