diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-07 11:06:49 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-07 11:06:49 (GMT) |
commit | 7ae7c87b058137537bdc2b7f1d8e585aa0245c1c (patch) | |
tree | c23f7910cea32d9381d663c46c68123094601f71 /Modules/getpath.c | |
parent | afa88b5dac1b068ccc33b65cd4da400a290b137e (diff) | |
download | cpython-7ae7c87b058137537bdc2b7f1d8e585aa0245c1c.zip cpython-7ae7c87b058137537bdc2b7f1d8e585aa0245c1c.tar.gz cpython-7ae7c87b058137537bdc2b7f1d8e585aa0245c1c.tar.bz2 |
_wrealpath() and _Py_wreadlink() support surrogates (PEP 383)
Use _Py_wchar2char() to support surrogate characters in the input path.
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r-- | Modules/getpath.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c index 6f2e537..06d0cae 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -179,15 +179,18 @@ _wgetcwd(wchar_t *buf, size_t size) int _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz) { + char *cpath; char cbuf[PATH_MAX]; - char cpath[PATH_MAX]; int res; - size_t r1 = wcstombs(cpath, path, PATH_MAX); - if (r1 == (size_t)-1 || r1 >= PATH_MAX) { + size_t r1; + + cpath = _Py_wchar2char(path); + if (cpath == NULL) { errno = EINVAL; return -1; } res = (int)readlink(cpath, cbuf, PATH_MAX); + PyMem_Free(cpath); if (res == -1) return -1; if (res == PATH_MAX) { |