summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-07-31 14:55:02 +0200
committerJulian Andres Klode <jak@debian.org>2009-07-31 14:55:02 +0200
commitc41f809bef5b591d36d6bbb663841a9434eb77fb (patch)
treeee44a80c5bfcc8be0c2872b4093d62c83b84cc30 /python
parentebe1f37a65cae8303bf86da13f3f2107cd73d1fe (diff)
downloadpython-apt-c41f809bef5b591d36d6bbb663841a9434eb77fb.tar.gz
python/configuration.cc, apt_pkgmodule.cc: Fix Configuration segfaults.
In apt_pkgmodule, change the type to Configuration*. In configuration.cc, check that GetSelf(Self).Tree(0) != 0 before doing GetSelf(Self).Tree(0)->Parent.
Diffstat (limited to 'python')
-rw-r--r--python/apt_pkgmodule.cc2
-rw-r--r--python/configuration.cc4
2 files changed, 4 insertions, 2 deletions
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index 9e486a91..d53f64a6 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -56,7 +56,7 @@ static PyObject *newConfiguration(PyObject *self,PyObject *args)
{
PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.newConfiguration() is "
"deprecated. Use apt_pkg.Configuration() instead.", 1);
- return CppPyObject_NEW<Configuration>(&PyConfiguration_Type);
+ return CppOwnedPyObject_NEW<Configuration*>(NULL, &PyConfiguration_Type, new Configuration());
}
#endif
/*}}}*/
diff --git a/python/configuration.cc b/python/configuration.cc
index 11231a28..b2367c3e 100644
--- a/python/configuration.cc
+++ b/python/configuration.cc
@@ -152,6 +152,8 @@ static PyObject *CnfList(PyObject *Self,PyObject *Args)
// Convert the whole configuration space into a list
PyObject *List = PyList_New(0);
const Configuration::Item *Top = GetSelf(Self).Tree(RootName);
+ if (!GetSelf(Self).Tree(0))
+ return List;
const Configuration::Item *Root = GetSelf(Self).Tree(0)->Parent;
if (Top != 0 && RootName != 0)
Top = Top->Child;
@@ -216,7 +218,7 @@ static PyObject *CnfKeys(PyObject *Self,PyObject *Args)
const Configuration::Item *Root = 0;
if (RootName == 0)
Stop = 0;
- if (Top != 0)
+ if (Top != 0 && GetSelf(Self).Tree(0))
Root = GetSelf(Self).Tree(0)->Parent;
for (; Top != 0;)
{