[ctypes-commit] ctypes/source cfield.c,1.49,1.50
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2004-10-12 09:32:44
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13654 Modified Files: cfield.c Log Message: Fix some *very* strange code. Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** cfield.c 12 Oct 2004 09:14:58 -0000 1.49 --- cfield.c 12 Oct 2004 09:32:27 -0000 1.50 *************** *** 690,693 **** --- 690,694 ---- PyObject *result; unsigned int len; + Py_UNICODE *p; size /= sizeof(wchar_t); /* we count character units here, not bytes */ *************** *** 702,710 **** */ /* chop off at the first NUL character, if any. */ ! /* XXX FIXME: But it seems wcslen would access forbidden memory locations ! if the original pointer was not zero terminated */ - /* Anyway, this is very strange code */ - len = wcslen(PyUnicode_AS_UNICODE(result)); if (len < size) { PyObject *ob = PyUnicode_FromWideChar((wchar_t *)ptr, len); --- 703,711 ---- */ /* chop off at the first NUL character, if any. */ ! p = PyUnicode_AS_UNICODE(result); ! for (len = 0; len < size; ++len) ! if (!p[len]) ! break; if (len < size) { PyObject *ob = PyUnicode_FromWideChar((wchar_t *)ptr, len); *************** *** 869,876 **** } else Py_INCREF(value); - #ifdef HAVE_USABLE_WCHAR_T *(wchar_t **)ptr = PyUnicode_AS_UNICODE(value); #else ! #error FIXME #endif return value; --- 870,877 ---- } else Py_INCREF(value); *(wchar_t **)ptr = PyUnicode_AS_UNICODE(value); + #ifdef HAVE_USABLE_WCHAR_T #else ! //#error FIXME #endif return value; |