From 6416834a8acac7971218c5f4a07b352226dd8774 Mon Sep 17 00:00:00 2001 From: "zainnadeem(RedOpsCell)" Date: Sat, 20 Jun 2026 15:05:32 +0500 Subject: [PATCH 1/3] gh-151763: Fix OOM NULL check in ntpath normpath --- Modules/posixmodule.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 1f1b7fa729c01c8..c52d2e7d5bfbd9f 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)); } From ef4a99abd3a779acc9c04cc08494399d8ce5caf7 Mon Sep 17 00:00:00 2001 From: "zainnadeem(RedOpsCell)" Date: Sat, 20 Jun 2026 15:19:18 +0500 Subject: [PATCH 2/3] gh-151763: Add NEWS entry for OOM-0028 fix --- .../2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst new file mode 100644 index 000000000000000..8e0ee35dfb412e9 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst @@ -0,0 +1,4 @@ +Fix a possible NULL dereference in ``os.path.normpath()`` for bytes paths +when memory allocation fails. The function now correctly propagates +``MemoryError`` instead of passing a NULL object to +``PyUnicode_EncodeFSDefault()``. From 73a2b50d2c7cef8e5b8125e635487b59ac7ea8e6 Mon Sep 17 00:00:00 2001 From: "zainnadeem(RedOpsCell)" Date: Sat, 20 Jun 2026 16:06:07 +0500 Subject: [PATCH 3/3] gh-151763: Move NEWS entry to Library --- .../2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/{Core_and_Builtins => Library}/2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst (100%) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst b/Misc/NEWS.d/next/Library/2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst similarity index 100% rename from Misc/NEWS.d/next/Core_and_Builtins/2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst rename to Misc/NEWS.d/next/Library/2026-06-20-15-18-46.gh-issue-151763.t-jCFF.rst