Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 350147b

Browse files
author
Victor Stinner
committed
_Py_wreadlink(): catch _Py_char2wchar() failure
1 parent 3f711f4 commit 350147b

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Python/fileutils.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz)
326326
}
327327
cbuf[res] = '\0'; /* buf will be null terminated */
328328
wbuf = _Py_char2wchar(cbuf);
329+
if (wbuf == NULL) {
330+
errno = EINVAL;
331+
return -1;
332+
}
329333
r1 = wcslen(wbuf);
330334
if (bufsiz <= r1) {
331335
PyMem_Free(wbuf);

0 commit comments

Comments
 (0)