summaryrefslogtreecommitdiffstats
path: root/Python/fileutils.c
diff options
context:
space:
mode:
authorMax Bachmann <kontakt@maxbachmann.de>2023-03-25 23:35:00 (GMT)
committerGitHub <noreply@github.com>2023-03-25 23:35:00 (GMT)
commitb28f919007439b48a1d00d54134d7b020a683cda (patch)
tree71fb4e55eec18b1c3cfbb077d7dfb6f91945b431 /Python/fileutils.c
parente1094c6e6a63637beacec731eced2c98bd076920 (diff)
downloadcpython-b28f919007439b48a1d00d54134d7b020a683cda.zip
cpython-b28f919007439b48a1d00d54134d7b020a683cda.tar.gz
cpython-b28f919007439b48a1d00d54134d7b020a683cda.tar.bz2
[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/fileutils.c')
-rw-r--r--Python/fileutils.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 2792426..c86ed40 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;
}