_Py_wreadlink(): catch _Py_char2wchar() failure

This commit is contained in:
Victor Stinner 2010-10-16 22:52:09 +00:00
parent 3f711f4a3e
commit 350147b5ca
1 changed files with 4 additions and 0 deletions

View File

@ -326,6 +326,10 @@ _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz)
}
cbuf[res] = '\0'; /* buf will be null terminated */
wbuf = _Py_char2wchar(cbuf);
if (wbuf == NULL) {
errno = EINVAL;
return -1;
}
r1 = wcslen(wbuf);
if (bufsiz <= r1) {
PyMem_Free(wbuf);