Skip to content

Commit ed1add4

Browse files
sobolevnmiss-islington
authored andcommitted
gh-151126: Fix missing memory error in os._path_splitroot (GH-151339)
(cherry picked from commit 10595b1) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent bba6886 commit ed1add4

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a crash when :exc:`MemoryError` in :func:`!os._path_splitroot`
2+
was not set properly.

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5133,7 +5133,7 @@ os__path_splitroot_impl(PyObject *module, path_t *path)
51335133

51345134
buffer = (wchar_t*)PyMem_Malloc(sizeof(wchar_t) * (wcslen(path->wide) + 1));
51355135
if (!buffer) {
5136-
return NULL;
5136+
return PyErr_NoMemory();
51375137
}
51385138
wcscpy(buffer, path->wide);
51395139
for (wchar_t *p = wcschr(buffer, L'/'); p; p = wcschr(p, L'/')) {

0 commit comments

Comments
 (0)