From 5a7b5d37b4d792f875bee54730b74bb5d5549712 Mon Sep 17 00:00:00 2001 From: "roberto@quantal64" Date: Sun, 8 Jul 2012 20:18:56 +0200 Subject: [PATCH] fix #138 --- plugins/python/python_plugin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index a1f2d9ca..a7ec1f3c 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -170,12 +170,13 @@ int uwsgi_python_init() { if (up.home != NULL) { #ifdef PYTHREE wchar_t *wpyhome; - wpyhome = malloc((sizeof(wchar_t) * strlen(up.home)) + sizeof(wchar_t) ); + size_t len = strlen(up.home) + 1; + wpyhome = uwsgi_calloc(sizeof(wchar_t) * len ); if (!wpyhome) { uwsgi_error("malloc()"); exit(1); } - mbstowcs(wpyhome, up.home, strlen(up.home)); + mbstowcs(wpyhome, up.home, len); Py_SetPythonHome(wpyhome); // do not free this memory !!! //free(wpyhome);