Visitar URL original
gh-110572: Fix leaks in `test_*_code` in `_testcapi/getargs.c` by sobolevn · Pull Request #110573 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review
  • Loading branch information
sobolevn committed Oct 9, 2023
commit 073b9156563012a43fabc4d3a794b466ab9977e4
13 changes: 11 additions & 2 deletions Modules/_testcapi/getargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ test_k_code(PyObject *self, PyObject *Py_UNUSED(ignored))
}

unsigned long value = PyLong_AsUnsignedLongMask(num);
Comment thread
sobolevn marked this conversation as resolved.
if (value != ULONG_MAX) {
if (value == (unsigned long)-1 && PyErr_Occurred()) {
Py_DECREF(num);
goto error;
}
else if (value != ULONG_MAX) {
Py_DECREF(num);
PyErr_SetString(PyExc_AssertionError,
"test_k_code: "
Expand Down Expand Up @@ -376,7 +380,12 @@ test_k_code(PyObject *self, PyObject *Py_UNUSED(ignored))
}

value = PyLong_AsUnsignedLongMask(num);
if (value != (unsigned long)-0x42) {
if (value == (unsigned long)-1 && PyErr_Occurred()) {
Py_DECREF(num);
goto error;
}
else if (value != (unsigned long)-0x42) {
Py_DECREF(num);
PyErr_SetString(PyExc_AssertionError,
"test_k_code: "
"PyLong_AsUnsignedLongMask() returned wrong value for long -0xFFF..000042");
Expand Down