Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb28f919

Browse files
authored
[3.11]gh-102281: Fix potential nullptr dereference + use of uninitia… (#103040)
[3.11]gh-102281: Fix potential nullptr dereference + use of uninitialized memory (gh-102282)(cherry picked from commitafa6092)
1 parente1094c6 commitb28f919

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix potential nullptr dereference and use of uninitialized memory in fileutils. Patch by Max Bachmann.

‎Modules/getpath.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,10 @@ getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args)
452452
if (s) {
453453
*s=L'\0';
454454
}
455-
path2=_Py_normpath(_Py_join_relfile(path,resolved),-1);
455+
path2=_Py_join_relfile(path,resolved);
456+
if (path2) {
457+
path2=_Py_normpath(path2,-1);
458+
}
456459
PyMem_RawFree((void*)path);
457460
path=path2;
458461
}

‎Python/fileutils.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2142,7 +2142,10 @@ _Py_join_relfile(const wchar_t *dirname, const wchar_t *relfile)
21422142
}
21432143
assert(wcslen(dirname)<MAXPATHLEN);
21442144
assert(wcslen(relfile)<MAXPATHLEN-wcslen(dirname));
2145-
join_relfile(filename,bufsize,dirname,relfile);
2145+
if (join_relfile(filename,bufsize,dirname,relfile)<0) {
2146+
PyMem_RawFree(filename);
2147+
returnNULL;
2148+
}
21462149
returnfilename;
21472150
}
21482151

@@ -2180,6 +2183,7 @@ _Py_find_basename(const wchar_t *filename)
21802183
wchar_t*
21812184
_Py_normpath(wchar_t*path,Py_ssize_tsize)
21822185
{
2186+
assert(path!=NULL);
21832187
if (!path[0]||size==0) {
21842188
returnpath;
21852189
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp