diff options
| author | Max Bachmann <kontakt@maxbachmann.de> | 2023-03-26 00:35:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-25 16:35:00 -0700 |
| commit | b28f919007439b48a1d00d54134d7b020a683cda (patch) | |
| tree | 71fb4e55eec18b1c3cfbb077d7dfb6f91945b431 /Python | |
| parent | e1094c6e6a63637beacec731eced2c98bd076920 (diff) | |
| download | python-b28f919007439b48a1d00d54134d7b020a683cda.tar.gz python-b28f919007439b48a1d00d54134d7b020a683cda.zip | |
[3.11] gh-102281: Fix potential nullptr dereference + use of uninitia… (#103040)
[3.11] gh-102281: Fix potential nullptr dereference + use of uninitialized memory (gh-102282)
(cherry picked from commit afa6092ee4260bacf7bc11905466e4c3f8556cbb)
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/fileutils.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c index 27924261f43..c86ed40b199 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -2142,7 +2142,10 @@ _Py_join_relfile(const wchar_t *dirname, const wchar_t *relfile) } assert(wcslen(dirname) < MAXPATHLEN); assert(wcslen(relfile) < MAXPATHLEN - wcslen(dirname)); - join_relfile(filename, bufsize, dirname, relfile); + if (join_relfile(filename, bufsize, dirname, relfile) < 0) { + PyMem_RawFree(filename); + return NULL; + } return filename; } @@ -2180,6 +2183,7 @@ _Py_find_basename(const wchar_t *filename) wchar_t * _Py_normpath(wchar_t *path, Py_ssize_t size) { + assert(path != NULL); if (!path[0] || size == 0) { return path; } |
