diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/depcache.cc | 3 | ||||
| -rw-r--r-- | python/generic.h | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/python/depcache.cc b/python/depcache.cc index b7294644..014ad7ae 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -997,7 +997,8 @@ static const char *actiongroup__exit__doc = "Same as release(), but for use as a context manager."; static PyObject *PkgActionGroupExit(PyObject *Self,PyObject *Args) { pkgDepCache::ActionGroup *ag = GetCpp<pkgDepCache::ActionGroup*>(Self); - ag->release(); + if (ag != NULL) + ag->release(); Py_RETURN_FALSE; } diff --git a/python/generic.h b/python/generic.h index 31c1bc2d..7abf7e7a 100644 --- a/python/generic.h +++ b/python/generic.h @@ -202,8 +202,10 @@ void CppDeallocPtr(PyObject *iObj) std::cerr << "=== DEALLOCATING " << iObj->ob_type->tp_name << "*+ ===\n"; #endif CppPyObject<T> *Obj = (CppPyObject<T> *)iObj; - if (!((CppPyObject<T>*)Obj)->NoDelete) + if (!((CppPyObject<T>*)Obj)->NoDelete) { delete Obj->Object; + Obj->Object = NULL; + } CppClear<T>(iObj); iObj->ob_type->tp_free(iObj); } |
