summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/getpath.c9
-rw-r--r--Python/sysmodule.c7
2 files changed, 10 insertions, 6 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) {
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 97809d2..e95a91f 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1661,16 +1661,17 @@ makeargvobject(int argc, wchar_t **argv)
static wchar_t*
_wrealpath(const wchar_t *path, wchar_t *resolved_path)
{
- char cpath[PATH_MAX];
+ char *cpath;
char cresolved_path[PATH_MAX];
char *res;
size_t r;
- r = wcstombs(cpath, path, PATH_MAX);
- if (r == (size_t)-1 || r >= PATH_MAX) {
+ cpath = _Py_wchar2char(path);
+ if (cpath == NULL) {
errno = EINVAL;
return NULL;
}
res = realpath(cpath, cresolved_path);
+ PyMem_Free(cpath);
if (res == NULL)
return NULL;
r = mbstowcs(resolved_path, cresolved_path, PATH_MAX);