summaryrefslogtreecommitdiff
path: root/Python/fileutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r--Python/fileutils.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 0c05424143..6345553f48 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -1668,8 +1668,9 @@ _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t buflen)
{
char *cpath;
char cbuf[MAXPATHLEN];
+ size_t cbuf_len = Py_ARRAY_LENGTH(cbuf);
wchar_t *wbuf;
- int res;
+ Py_ssize_t res;
size_t r1;
cpath = _Py_EncodeLocaleRaw(path, NULL);
@@ -1677,11 +1678,12 @@ _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t buflen)
errno = EINVAL;
return -1;
}
- res = (int)readlink(cpath, cbuf, Py_ARRAY_LENGTH(cbuf));
+ res = readlink(cpath, cbuf, cbuf_len);
PyMem_RawFree(cpath);
- if (res == -1)
+ if (res == -1) {
return -1;
- if (res == Py_ARRAY_LENGTH(cbuf)) {
+ }
+ if ((size_t)res == cbuf_len) {
errno = EINVAL;
return -1;
}