From: Zain Nadeem Date: Wed, 24 Jun 2026 15:56:10 +0000 (+0500) Subject: gh-151763: Fix NULL dereference in `os._path_normpath()` under OOM (#151779) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce8b81fff4094bd0cfb0c57193135bfc904c0ca2;p=thirdparty%2FPython%2Fcpython.git gh-151763: Fix NULL dereference in `os._path_normpath()` under OOM (#151779) --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 1f1b7fa729c0..c52d2e7d5bfb 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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)); }