summaryrefslogtreecommitdiff
path: root/Python/fileutils.c
diff options
context:
space:
mode:
authorMax Bachmann <kontakt@maxbachmann.de>2023-03-15 13:58:43 +0100
committerGitHub <noreply@github.com>2023-03-15 21:58:43 +0900
commitafa6092ee4260bacf7bc11905466e4c3f8556cbb (patch)
treeb55153f6a7c48b9fd6c6a8e17af44b7087914d72 /Python/fileutils.c
parent2b5781d659ce3ffe03d4c1f46e4875e604cf2d88 (diff)
downloadcpython-git-afa6092ee4260bacf7bc11905466e4c3f8556cbb.tar.gz
gh-102281: Fix potential nullptr dereference + use of uninitialized memory (gh-102282)
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 4ac759c45a..f48b626b44 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -2233,7 +2233,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;
}
@@ -2271,6 +2274,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;
}