diff options
author | Thomas Heller <theller@ctypes.org> | 2008-07-15 17:25:07 (GMT) |
---|---|---|
committer | Thomas Heller <theller@ctypes.org> | 2008-07-15 17:25:07 (GMT) |
commit | 0261e1e73f14da7ce2c50ad2a93390a31cae2179 (patch) | |
tree | b0aa393b3fab8775da31cf0c56a15da434bfcdf9 /Modules | |
parent | d88ddfa94ae112957e49093550c096415ef0cd33 (diff) | |
download | cpython-0261e1e73f14da7ce2c50ad2a93390a31cae2179.zip cpython-0261e1e73f14da7ce2c50ad2a93390a31cae2179.tar.gz cpython-0261e1e73f14da7ce2c50ad2a93390a31cae2179.tar.bz2 |
Merged revisions 64968,64971 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64968 | thomas.heller | 2008-07-15 19:03:08 +0200 (Di, 15 Jul 2008) | 4 lines
Issue #3258: Fix an assertion error (in debug build) and a crash (in
release build) when the format string of a pointer to an incomplete
structure is created.
........
r64971 | thomas.heller | 2008-07-15 19:19:50 +0200 (Di, 15 Jul 2008) | 2 lines
NEWS entry for #issue 3258.
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index c4ca29a..48fe772 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -353,6 +353,11 @@ StructUnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds, int isSt } Py_DECREF(result->tp_dict); result->tp_dict = (PyObject *)dict; + dict->format = alloc_format_string(NULL, "B"); + if (dict->format == NULL) { + Py_DECREF(result); + return NULL; + } dict->paramfunc = StructUnionType_paramfunc; @@ -871,7 +876,13 @@ PointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (proto) { StgDictObject *itemdict = PyType_stgdict(proto); assert(itemdict); - stgdict->format = alloc_format_string("&", itemdict->format); + /* If itemdict->format is NULL, then this is a pointer to an + incomplete type. We create a generic format string + 'pointer to bytes' in this case. XXX Better would be to + fix the format string later... + */ + stgdict->format = alloc_format_string("&", + itemdict->format ? itemdict->format : "B"); if (stgdict->format == NULL) { Py_DECREF((PyObject *)stgdict); return NULL; |