Browse Source

[2438] make sure cppobj is NULL in the base RRsetCollection wrapper classs.

JINMEI Tatuya 12 years ago
parent
commit
81ed5b0185
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/lib/dns/python/rrset_collection_python.cc

+ 7 - 2
src/lib/dns/python/rrset_collection_python.cc

@@ -70,8 +70,13 @@ RRsetCollectionBase_init(PyObject*, PyObject*, PyObject*) {
 void
 RRsetCollectionBase_destroy(PyObject* po_self) {
     s_RRsetCollection* self = static_cast<s_RRsetCollection*>(po_self);
-    delete self->cppobj;
-    self->cppobj = NULL;
+
+    // Any C++-wrapper of derived RRsetCollection class should have its own
+    // destroy function (as it may manage cppobj in its own way);
+    // Python-only derived classes shouldn't set cppobj (which is
+    // 0-initialized).  So this assertion must hold.
+    assert(self->cppobj == NULL);
+
     Py_TYPE(self)->tp_free(self);
 }