diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-03-08 10:54:31 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-03-08 10:54:31 (GMT) |
commit | a69e1efbfb38b2a9826781a8cb5c20991525ba03 (patch) | |
tree | 525958bd713cb14598388544500215263356ec0f /Modules/_localemodule.c | |
parent | 92fab7569dbda9153fab99b31e6a2aa2e9821a56 (diff) | |
download | cpython-a69e1efbfb38b2a9826781a8cb5c20991525ba03.zip cpython-a69e1efbfb38b2a9826781a8cb5c20991525ba03.tar.gz cpython-a69e1efbfb38b2a9826781a8cb5c20991525ba03.tar.bz2 |
Properly size memory blocks in units of wchar_t.
Diffstat (limited to 'Modules/_localemodule.c')
-rw-r--r-- | Modules/_localemodule.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index 8a32677..0b657c4 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -61,7 +61,7 @@ str2uni(const char* s) if (needed < sizeof(smallbuf)) dest = smallbuf; else { - dest = PyMem_Malloc(needed+1); + dest = PyMem_Malloc((needed+1)*sizeof(wchar_t)); if (!dest) return PyErr_NoMemory(); } @@ -282,7 +282,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args) #ifdef HAVE_USABLE_WCHAR_T s = s0; #else - s = PyMem_Malloc(n0+1); + s = PyMem_Malloc((n0+1)*sizeof(wchar_t)); if (!s) return PyErr_NoMemory(); for (i=0; i<=n0; i++) @@ -291,7 +291,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args) /* assume no change in size, first */ n1 = wcslen(s) + 1; - buf = PyMem_Malloc(n1); + buf = PyMem_Malloc(n1*sizeof(wchar_t)); if (!buf) { PyErr_NoMemory(); goto exit; @@ -299,7 +299,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args) n2 = wcsxfrm(buf, s, n1); if (n2 >= n1) { /* more space needed */ - buf = PyMem_Realloc(buf, n2+1); + buf = PyMem_Realloc(buf, (n2+1)*sizeof(wchar_t)); if (!buf) { PyErr_NoMemory(); goto exit; |