This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unreachable Py_DECREF() in ctypes's PyCData_FromBaseObj()
Type: resource usage Stage: resolved
Components: Extension Modules Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, eric.smith, python-dev
Priority: low Keywords: patch

Created on 2013-07-20 12:40 by christian.heimes, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg193406 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-20 12:40
http://hg.python.org/cpython/file/a65856044ad4/Modules/_ctypes/_ctypes.c#l2673

Coverity analysis:

2672    } else { /* copy contents of adr */
2673        if (-1 == PyCData_MallocBuffer(cmem, dict)) {
2674            return NULL;
    
CID 715381: Structurally dead code (UNREACHABLE)unreachable: This code cannot be reached: "do {
PyObject *_py_decref...".
2675            Py_DECREF(cmem);
2676        }
msg193445 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2013-07-21 13:46
Your patch looks like the output of "hg help", or similar.
msg193447 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-21 14:06
Oh, you are right ...

The patch is trivial: I switched the Py_DECREF() and return NULL lines.
msg193448 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2013-07-21 14:09
For some reason the blank link in the Coverity report confused me. Yes, swapping the lines looks right.
msg193452 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-07-21 14:25
New changeset 25ffad2e12d6 by Christian Heimes in branch '3.3':
Issue #18514: Fix unreachable Py_DECREF() call in PyCData_FromBaseObj()
http://hg.python.org/cpython/rev/25ffad2e12d6

New changeset afe119a3619f by Christian Heimes in branch 'default':
Issue #18514: Fix unreachable Py_DECREF() call in PyCData_FromBaseObj()
http://hg.python.org/cpython/rev/afe119a3619f
msg193453 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-21 14:26
Thanks for the review
History
Date User Action Args
2022-04-11 14:57:48adminsetgithub: 62714
2013-07-21 14:26:59christian.heimessetstatus: open -> closed
resolution: fixed
messages: + msg193453

stage: needs patch -> resolved
2013-07-21 14:25:41python-devsetnosy: + python-dev
messages: + msg193452
2013-07-21 14:09:04eric.smithsetmessages: + msg193448
2013-07-21 14:06:54christian.heimessetmessages: + msg193447
2013-07-21 14:05:41christian.heimessetfiles: - frombaseobj.patch
2013-07-21 13:46:26eric.smithsetnosy: + eric.smith
messages: + msg193445
2013-07-20 12:40:37christian.heimescreate