diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-06-09 17:29:57 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-06-09 17:29:57 +0200 |
| commit | fc874b8b9507401a232d42fa7936148f76b0a1e2 (patch) | |
| tree | a1245d363d3439afa74c9d1a8ec2949622076ae7 /python | |
| parent | b7f2997fc11283801260f54e9d84610265279aa0 (diff) | |
| download | python-apt-fc874b8b9507401a232d42fa7936148f76b0a1e2.tar.gz | |
python/cache.cc: Fix segfaults using the new allocation methods.
We switched to using tp_alloc() to create new objects. Some types
had no tp_flags set and were not initialized using PyType_Ready,
causing tp_alloc (PyType_GenericAlloc) to crash.
Diffstat (limited to 'python')
| -rw-r--r-- | python/apt_pkgmodule.cc | 5 | ||||
| -rw-r--r-- | python/cache.cc | 20 |
2 files changed, 22 insertions, 3 deletions
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 085d12f4..95b72de4 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -547,6 +547,7 @@ extern "C" void initapt_pkg() // Finalize our types to add slots, etc. if (PyType_Ready(&ConfigurationPtrType) == -1) INIT_ERROR; if (PyType_Ready(&ConfigurationSubType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgCacheFileType) == -1) INIT_ERROR; // Initialize the module #if PY_MAJOR_VERSION >= 3 @@ -577,8 +578,8 @@ extern "C" void initapt_pkg() ADDTYPE(Module,"Dependency",&DependencyType); // NO __new__() ADDTYPE(Module,"Description",&DescriptionType); // NO __new__() ADDTYPE(Module,"PackageFile",&PackageFileType); // NO __new__() - //ADDTYPE(Module,"PackageList",&PkgListType); // NO __new__(), internal - //ADDTYPE(Module,"DependencyList",&RDepListType); // NO __new__(), internal + ADDTYPE(Module,"PackageList",&PkgListType); // NO __new__(), internal + ADDTYPE(Module,"DependencyList",&RDepListType); // NO __new__(), internal ADDTYPE(Module,"Package",&PackageType); // NO __new__() ADDTYPE(Module,"Version",&VersionType); // NO __new__() /* ============================ cdrom.cc ============================ */ diff --git a/python/cache.cc b/python/cache.cc index 38b715de..c988145f 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -374,6 +374,12 @@ PyTypeObject PkgCacheFileType = 0, // tp_as_sequence 0, // tp_as_mapping 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT, // tp_flags }; /*}}}*/ // Package List Class /*{{{*/ @@ -444,6 +450,12 @@ PyTypeObject PkgListType = &PkgListSeq, // tp_as_sequence 0, // tp_as_mapping 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT , // tp_flags }; #define MkGet(PyFunc,Ret) static PyObject *PyFunc(PyObject *Self,void*) \ @@ -656,7 +668,7 @@ PyTypeObject DescriptionType = 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags - "AcquireItem Object", // tp_doc + "apt_pkg.Description Object", // tp_doc 0, // tp_traverse 0, // tp_clear 0, // tp_richcompare @@ -1340,6 +1352,12 @@ PyTypeObject RDepListType = &RDepListSeq, // tp_as_sequence 0, // tp_as_mapping 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT, // tp_flags }; /*}}}*/ |
