[issue44285] Coverity scan: Modules/getpath.c. "calculate_open_pyenv" allocates memory that is stored into "env_file".

Charalampos Stratakis report at bugs.python.org
Wed Jun 2 09:39:39 EDT 2021


New submission from Charalampos Stratakis <cstratak at redhat.com>:

This is an issue as it seems with coverity as it's an error case where the file was not actually opened. This warning can be silenced and the code be made more explicit by adding an assertion.

Python-3.9.1/Modules/getpath.c:1264: alloc_arg: "calculate_open_pyenv" allocates memory that is stored into "env_file".
Python-3.9.1/Modules/getpath.c:1266: leaked_storage: Variable "env_file" going out of scope leaks the storage it points to.
# 1264|       status = calculate_open_pyenv(calculate, &env_file);
# 1265|       if (_PyStatus_EXCEPTION(status)) {
# 1266|->         return status;
# 1267|       }
# 1268|       if (env_file == NULL) {

----------
messages: 394906
nosy: cstratak
priority: normal
severity: normal
status: open
title: Coverity scan: Modules/getpath.c. "calculate_open_pyenv" allocates memory that is stored into "env_file".
versions: Python 3.10, Python 3.11, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44285>
_______________________________________


More information about the Python-bugs-list mailing list