bpo-36745: Fix a possible reference leak in PyObject_SetAttr() (GH-12… · python/cpython@896c635 (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit 896c635
and
authored
File tree
1 file changed
lines changed
1 file changed
lines changed
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1017,8 +1017,10 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value) | ||
1017 | 1017 | } |
1018 | 1018 | if (tp->tp_setattr != NULL) { |
1019 | 1019 | const char *name_str = PyUnicode_AsUTF8(name); |
1020 | -if (name_str == NULL) | |
1020 | +if (name_str == NULL) { | |
1021 | +Py_DECREF(name); | |
1021 | 1022 | return -1; |
1023 | + } | |
1022 | 1024 | err = (*tp->tp_setattr)(v, (char *)name_str, value); |
1023 | 1025 | Py_DECREF(name); |
1024 | 1026 | return err; |