diff options
author | Armin Rigo <arigo@tunes.org> | 2020-07-06 21:13:08 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-07-06 21:13:08 +0200 |
commit | 91dfef348250ffaf7acda85834f5eb09b43be2f7 (patch) | |
tree | ac3d439b57b9237d18a894968922b679baff9dcf | |
parent | edb39f03e3841dc682f2517c7c1020397dcfc6c2 (diff) | |
download | cffi-91dfef348250ffaf7acda85834f5eb09b43be2f7.tar.gz |
windows fix
-rw-r--r-- | c/_cffi_backend.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c index e2ad390..71e22f1 100644 --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -4454,6 +4454,8 @@ static void *b_do_dlopen(PyObject *args, const char **p_printable_filename, PyObject *filename_unicode; if (PyArg_ParseTuple(args, "U|i:load_library", &filename_unicode, &flags)) { + Py_ssize_t sz1; + wchar_t *w1; #if PY_MAJOR_VERSION < 3 s = PyUnicode_AsUTF8String(s); if (s == NULL) @@ -4464,10 +4466,11 @@ static void *b_do_dlopen(PyObject *args, const char **p_printable_filename, if (*p_printable_filename == NULL) return NULL; - Py_ssize_t sz1 = PyUnicode_GetSize(filename_unicode) + 1; + sz1 = PyUnicode_GetSize(filename_unicode) + 1; sz1 *= 2; /* should not be needed, but you never know */ - wchar_t *w1 = alloca(sizeof(wchar_t) * sz1); - sz1 = PyUnicode_AsWideChar(filename_unicode, w1, sz1 - 1); + w1 = alloca(sizeof(wchar_t) * sz1); + sz1 = PyUnicode_AsWideChar((PyUnicodeObject *)filename_unicode, + w1, sz1 - 1); if (sz1 < 0) return NULL; w1[sz1] = 0; |