]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
_Py_wreadlink(): catch _Py_char2wchar() failure
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 16 Oct 2010 22:52:09 +0000 (22:52 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 16 Oct 2010 22:52:09 +0000 (22:52 +0000)
Python/fileutils.c

index cfafd865c54d222906b9092b0f4db84322954fd6..147636f2c78957c5b63cfba64665e2a330453824 100644 (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);