gh-102281: Fix potential nullptr dereference + use of uninitialized m… · python/cpython@afa6092 · GitHub
Skip to content

Commit afa6092

Browse files
authored
gh-102281: Fix potential nullptr dereference + use of uninitialized memory (gh-102282)
1 parent 2b5781d commit afa6092

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions

Modules/getpath.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args)
446446
if (s) {
447447
*s = L'\0';
448448
}
449-
path2 = _Py_normpath(_Py_join_relfile(path, resolved), -1);
449+
path2 = _Py_join_relfile(path, resolved);
450+
if (path2) {
451+
path2 = _Py_normpath(path2, -1);
452+
}
450453
PyMem_RawFree((void *)path);
451454
path = path2;
452455
}

Python/fileutils.c

Lines changed: 5 additions & 1 deletion

0 commit comments

Comments
 (0)