Issue 18556: ctypes' U_set() doesn't check return value of PyUnicode_AsWideChar() (original) (raw)
Issue18556
Created on 2013-07-25 16:52 by christian.heimes, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (4) | ||
---|---|---|
msg193703 - (view) | Author: Christian Heimes (christian.heimes) * ![]() |
Date: 2013-07-25 16:52 |
http://hg.python.org/cpython/file/be5f1f0bea09/Modules/_ctypes/cfield.c#l1235 CID 486657 (#1 of 1): Unchecked return value (CHECKED_RETURN) 5. check_return: Calling function "PyUnicode_AsWideChar(PyObject *, wchar_t *, Py_ssize_t)" without checking return value (as is done elsewhere 7 out of 8 times). 1263 PyUnicode_AsWideChar(value, (wchar_t *)ptr, size); | ||
msg193715 - (view) | Author: Matthew Barnett (mrabarnett) * ![]() |
Date: 2013-07-25 19:28 |
Re : A little before that, 'value' is INCREF'ed, and then: wstr = PyUnicode_AsUnicodeAndSize(value, &size); if (wstr == NULL) return NULL; Shouldn't 'value' be DECREF'ed before returning? | ||
msg193720 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2013-07-25 21:36 |
New changeset 78e8980ec9f7 by Brett Cannon in branch '3.3': Issue #18556: Check the return value for PyUnicode_AsWideChar() in http://hg.python.org/cpython/rev/78e8980ec9f7 New changeset 2f4c4db9aee5 by Brett Cannon in branch 'default': merge for issue #18556 http://hg.python.org/cpython/rev/2f4c4db9aee5 | ||
msg193722 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2013-07-25 21:37 |
Thanks for the check, Matthew, but if you look at the other *_set() methods they do not necessarily DECREF their 'value' argument. Plus if PyUnicode_AsWideChar() fails it means memory is full or a fatal error has triggered, so there are bigger worries. =) |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:48 | admin | set | github: 62756 |
2013-07-25 21:37:45 | brett.cannon | set | status: open -> closednosy: + brett.cannonmessages: + resolution: fixedstage: needs patch -> resolved |
2013-07-25 21:36:39 | python-dev | set | nosy: + python-devmessages: + |
2013-07-25 19:28:43 | mrabarnett | set | nosy: + mrabarnettmessages: + |
2013-07-25 16:52:29 | christian.heimes | create |