summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/acquire.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/python/acquire.cc b/python/acquire.cc
index 8b6de173..9104644d 100644
--- a/python/acquire.cc
+++ b/python/acquire.cc
@@ -112,6 +112,12 @@ static PyObject *AcquireItemRepr(PyObject *Self)
static void AcquireItemDealloc(PyObject *self) {
pkgAcquire::Item *file = GetCpp<pkgAcquire::Item*>(self);
PyAcquireObject *owner = (PyAcquireObject *)GetOwner<pkgAcquire::Item*>(self);
+
+ // Simply deallocate the object if we have no owner.
+ if (owner == NULL) {
+ CppOwnedDeallocPtr<pkgAcquire::Item*>(self);
+ return;
+ }
vector<PyAcquireItemObject *> &items = owner->items;
bool DeletePtr = !((CppPyObject<pkgAcquire::Item*> *)self)->NoDelete;