diff options
author | Ammar Askar <ammar@ammaraskar.com> | 2020-06-01 17:21:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-01 17:21:43 (GMT) |
commit | 06e3a27a3c863495390a07c695171a8e62a6e0d2 (patch) | |
tree | 9d2d738971d6a057717c5f233d40a53a94121064 /Modules/_sre.c | |
parent | a97011b9b8c8111f42e1e7594081956136d848da (diff) | |
download | cpython-06e3a27a3c863495390a07c695171a8e62a6e0d2.zip cpython-06e3a27a3c863495390a07c695171a8e62a6e0d2.tar.gz cpython-06e3a27a3c863495390a07c695171a8e62a6e0d2.tar.bz2 |
bpo-39943: Fix MSVC warnings in sre extension (GH-20508)
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r-- | Modules/_sre.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c index 244e4f1..bdc4278 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -454,7 +454,10 @@ state_init(SRE_STATE* state, PatternObject* pattern, PyObject* string, return string; err: - PyMem_Del(state->mark); + /* We add an explicit cast here because MSVC has a bug when + compiling C code where it believes that `const void**` cannot be + safely casted to `void*`, see bpo-39943 for details. */ + PyMem_Del((void*) state->mark); state->mark = NULL; if (state->buffer.buf) PyBuffer_Release(&state->buffer); @@ -468,7 +471,8 @@ state_fini(SRE_STATE* state) PyBuffer_Release(&state->buffer); Py_XDECREF(state->string); data_stack_dealloc(state); - PyMem_Del(state->mark); + /* See above PyMem_Del for why we explicitly cast here. */ + PyMem_Del((void*) state->mark); state->mark = NULL; } |