Commit 313b4132 authored by Martin v. Löwis's avatar Martin v. Löwis

Properly size memory blocks in units of wchar_t.

parent 24beb313
...@@ -61,7 +61,7 @@ str2uni(const char* s) ...@@ -61,7 +61,7 @@ str2uni(const char* s)
if (needed < sizeof(smallbuf)) if (needed < sizeof(smallbuf))
dest = smallbuf; dest = smallbuf;
else { else {
dest = PyMem_Malloc(needed+1); dest = PyMem_Malloc((needed+1)*sizeof(wchar_t));
if (!dest) if (!dest)
return PyErr_NoMemory(); return PyErr_NoMemory();
} }
...@@ -282,7 +282,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args) ...@@ -282,7 +282,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
#ifdef HAVE_USABLE_WCHAR_T #ifdef HAVE_USABLE_WCHAR_T
s = s0; s = s0;
#else #else
s = PyMem_Malloc(n0+1); s = PyMem_Malloc((n0+1)*sizeof(wchar_t));
if (!s) if (!s)
return PyErr_NoMemory(); return PyErr_NoMemory();
for (i=0; i<=n0; i++) for (i=0; i<=n0; i++)
...@@ -291,7 +291,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args) ...@@ -291,7 +291,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
/* assume no change in size, first */ /* assume no change in size, first */
n1 = wcslen(s) + 1; n1 = wcslen(s) + 1;
buf = PyMem_Malloc(n1); buf = PyMem_Malloc(n1*sizeof(wchar_t));
if (!buf) { if (!buf) {
PyErr_NoMemory(); PyErr_NoMemory();
goto exit; goto exit;
...@@ -299,7 +299,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args) ...@@ -299,7 +299,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
n2 = wcsxfrm(buf, s, n1); n2 = wcsxfrm(buf, s, n1);
if (n2 >= n1) { if (n2 >= n1) {
/* more space needed */ /* more space needed */
buf = PyMem_Realloc(buf, n2+1); buf = PyMem_Realloc(buf, (n2+1)*sizeof(wchar_t));
if (!buf) { if (!buf) {
PyErr_NoMemory(); PyErr_NoMemory();
goto exit; goto exit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment