summaryrefslogtreecommitdiffstats
path: root/Modules/clinic
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-08-11 18:13:46 (GMT)
committerGitHub <noreply@github.com>2023-08-11 18:13:46 (GMT)
commit04cc01453db2f0af72a06440831637f8bf512daf (patch)
tree84854fa4bd5b10588eef404a2c22fe65ad25a244 /Modules/clinic
parenta39f0a350662f1978104ee1136472d784aa6f29c (diff)
downloadcpython-04cc01453db2f0af72a06440831637f8bf512daf.zip
cpython-04cc01453db2f0af72a06440831637f8bf512daf.tar.gz
cpython-04cc01453db2f0af72a06440831637f8bf512daf.tar.bz2
gh-106844: Fix issues in _winapi.LCMapStringEx (GH-107832)
* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError, it doesn't matter how much memory is available. * Strings with length exactly 2**32-1 caused OSError. * Strings longer than 2**32-1 characters were truncated due to integer overflow bug. * Strings containing the null character were truncated at the first null character. Now strings longer than 2**31-1 characters caused OverflowError and the null character is allowed.
Diffstat (limited to 'Modules/clinic')
-rw-r--r--Modules/clinic/_winapi.c.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/Modules/clinic/_winapi.c.h b/Modules/clinic/_winapi.c.h
index 8f46b8f..35ac053 100644
--- a/Modules/clinic/_winapi.c.h
+++ b/Modules/clinic/_winapi.c.h
@@ -884,7 +884,7 @@ PyDoc_STRVAR(_winapi_LCMapStringEx__doc__,
static PyObject *
_winapi_LCMapStringEx_impl(PyObject *module, LPCWSTR locale, DWORD flags,
- LPCWSTR src);
+ PyObject *src);
static PyObject *
_winapi_LCMapStringEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
@@ -911,16 +911,16 @@ _winapi_LCMapStringEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
static const char * const _keywords[] = {"locale", "flags", "src", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
- .format = "O&kO&:LCMapStringEx",
+ .format = "O&kU:LCMapStringEx",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
LPCWSTR locale = NULL;
DWORD flags;
- LPCWSTR src = NULL;
+ PyObject *src;
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- _PyUnicode_WideCharString_Converter, &locale, &flags, _PyUnicode_WideCharString_Converter, &src)) {
+ _PyUnicode_WideCharString_Converter, &locale, &flags, &src)) {
goto exit;
}
return_value = _winapi_LCMapStringEx_impl(module, locale, flags, src);
@@ -928,8 +928,6 @@ _winapi_LCMapStringEx(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
exit:
/* Cleanup for locale */
PyMem_Free((void *)locale);
- /* Cleanup for src */
- PyMem_Free((void *)src);
return return_value;
}
@@ -1480,4 +1478,4 @@ exit:
return return_value;
}
-/*[clinic end generated code: output=f32fe6ecdbffd74d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ff91ab5cae8961dd input=a9049054013a1b77]*/