summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2019-09-03 19:50:51 (GMT)
committerGitHub <noreply@github.com>2019-09-03 19:50:51 (GMT)
commit993ac92418839427d4068d6ae8e618b06b5d9294 (patch)
tree96b6441c09e4da1a050f12aae2eabd47362af09d /Modules/posixmodule.c
parent0cf832a9ef84be6e18aad02464814530d80b82b2 (diff)
downloadcpython-993ac92418839427d4068d6ae8e618b06b5d9294.zip
cpython-993ac92418839427d4068d6ae8e618b06b5d9294.tar.gz
cpython-993ac92418839427d4068d6ae8e618b06b5d9294.tar.bz2
bpo-38020: Fixes crash in os.readlink() on Windows (GH-15663)
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 2302678..c412d07 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7818,7 +7818,7 @@ os_readlink_impl(PyObject *module, path_t *path, int dir_fd)
HANDLE reparse_point_handle;
char target_buffer[_Py_MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
_Py_REPARSE_DATA_BUFFER *rdb = (_Py_REPARSE_DATA_BUFFER *)target_buffer;
- PyObject *result;
+ PyObject *result = NULL;
/* First get a handle to the reparse point */
Py_BEGIN_ALLOW_THREADS
@@ -7872,7 +7872,7 @@ os_readlink_impl(PyObject *module, path_t *path, int dir_fd)
name[1] = L'\\';
}
result = PyUnicode_FromWideChar(name, nameLen);
- if (path->narrow) {
+ if (result && path->narrow) {
Py_SETREF(result, PyUnicode_EncodeFSDefault(result));
}
}