[3.15] gh-151763: Fix NULL dereference in os._path_normpath() under OOM (GH-151779) (#152096)

(cherry picked from commit ce8b81fff4)

Co-authored-by: Zain Nadeem <zainnadeemzainnadeem80@gmail.com>
This commit is contained in:
Miss Islington (bot) 2026-06-24 18:25:28 +02:00 committed by GitHub
parent d4836f4d99
commit 4e7843ea3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6145,6 +6145,9 @@ os__path_normpath_impl(PyObject *module, path_t *path)
else {
result = PyUnicode_FromWideChar(norm_path, norm_len);
}
if (result == NULL) {
return NULL;
}
if (PyBytes_Check(path->object)) {
Py_SETREF(result, PyUnicode_EncodeFSDefault(result));
}