Issue36147
Created on 2019-02-28 18:03 by cstratak, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 12102 | merged | cstratak, 2019-02-28 18:11 | |
| Messages (4) | |||
|---|---|---|---|
| msg336859 - (view) | Author: Charalampos Stratakis (cstratak) * | Date: 2019-02-28 18:03 | |
Coverity scan on python2 resulted in this error. Python-2.7.15/Modules/_ctypes/cfield.c:1297: alloc_fn: Storage is returned from allocation function "PyString_FromString". Python-2.7.15/Objects/stringobject.c:143:5: alloc_fn: Storage is returned from allocation function "PyObject_Malloc". Python-2.7.15/Objects/obmalloc.c:982:5: alloc_fn: Storage is returned from allocation function "malloc". Python-2.7.15/Objects/obmalloc.c:982:5: return_alloc_fn: Directly returning storage allocated by "malloc". Python-2.7.15/Objects/stringobject.c:143:5: var_assign: Assigning: "op" = "PyObject_Malloc(37UL + size)". Python-2.7.15/Objects/stringobject.c:164:5: return_alloc: Returning allocated memory "op". Python-2.7.15/Modules/_ctypes/cfield.c:1297: var_assign: Assigning: "result" = storage returned from "PyString_FromString((char *)ptr)". Python-2.7.15/Modules/_ctypes/cfield.c:1311: leaked_storage: Variable "result" going out of scope leaks the storage it points to. 1309| } else 1310| /* cannot shorten the result */ 1311|-> return PyString_FromStringAndSize(ptr, size); 1312| } 1313| This was fixed on python3 with https://github.com/python/cpython/commit/19b52545df898ec911c44e29f75badb902924c0b Partially backporting this change for this file should fix the issue. |
|||
| msg336861 - (view) | Author: Charalampos Stratakis (cstratak) * | Date: 2019-02-28 18:10 | |
Also the change from PyUnicode_FromStringAndSize to PyBytes_FromStringAndSize happened here: https://bugs.python.org/issue8966 |
|||
| msg337303 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2019-03-06 14:14 | |
New changeset 098b139816f379271b8d4de2561b5805dd47d229 by Victor Stinner (stratakis) in branch '2.7': bpo-36147: Fix a memory leak in ctypes s_get() (GH-12102) https://github.com/python/cpython/commit/098b139816f379271b8d4de2561b5805dd47d229 |
|||
| msg337305 - (view) | Author: STINNER Victor (vstinner) * ![]() |
Date: 2019-03-06 14:34 | |
Thanks Charalampos Stratakis! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:11 | admin | set | github: 80328 |
| 2019-03-06 14:34:22 | vstinner | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2019-03-06 14:34:14 | vstinner | set | messages: + msg337305 |
| 2019-03-06 14:14:10 | vstinner | set | messages: + msg337303 |
| 2019-02-28 18:11:01 | cstratak | set | keywords:
+ patch stage: patch review pull_requests: + pull_request12108 |
| 2019-02-28 18:10:18 | cstratak | set | messages: + msg336861 |
| 2019-02-28 18:03:20 | cstratak | create | |
