diff options
author | Alexey Izbyshev <izbyshev@ispras.ru> | 2018-08-25 02:34:56 +0300 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-08-25 01:34:56 +0200 |
commit | eb746dbae8b320758ee08f811316d7f283435cc0 (patch) | |
tree | a98092c4b2df5bffbfcf8420e1cfa8c60233e07b /Python/coreconfig.c | |
parent | 3738fadc670274ecc4649f51b52a93602820a375 (diff) | |
download | cpython-git-eb746dbae8b320758ee08f811316d7f283435cc0.tar.gz |
bpo-34492: Python/coreconfig.c: Fix _Py_wstrlist_copy() (GH-8910)
bpo-34492: Python/coreconfig.c: Add missing NULL check to _Py_wstrlist_copy().
Fix _Py_wstrlist_clear() call on a wrong list.
Reported by Svace static analyzer.
Diffstat (limited to 'Python/coreconfig.c')
-rw-r--r-- | Python/coreconfig.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/coreconfig.c b/Python/coreconfig.c index 1a32525b7b..1b9e26e50a 100644 --- a/Python/coreconfig.c +++ b/Python/coreconfig.c @@ -69,10 +69,13 @@ _Py_wstrlist_copy(int len, wchar_t **list) assert((len > 0 && list != NULL) || len == 0); size_t size = len * sizeof(list[0]); wchar_t **list_copy = PyMem_RawMalloc(size); + if (list_copy == NULL) { + return NULL; + } for (int i=0; i < len; i++) { wchar_t* arg = _PyMem_RawWcsdup(list[i]); if (arg == NULL) { - _Py_wstrlist_clear(i, list); + _Py_wstrlist_clear(i, list_copy); return NULL; } list_copy[i] = arg; |