[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Wed Dec 8 23:28:04 UTC 2004


CVS commit by okellogg: 

getObjectId(): Check for NULL pointer at the role object.


  M +21 -3     association.cpp   1.58


--- kdesdk/umbrello/umbrello/association.cpp  #1.57:1.58
@@ -52,6 +52,18 @@ UMLAssociation::~UMLAssociation( ) {
         // delete ourselves from the parent document
         UMLApp::app()->getDocument()->removeAssociation(this);
+        if (m_pRole[A] == NULL) {
+                kdError() << "UMLAssociation destructor: m_pRole[A] is NULL already"
+                          << endl;
+        } else {
         delete m_pRole[A];
+                m_pRole[A] = NULL;
+        }
+        if (m_pRole[B] == NULL) {
+                kdError() << "UMLAssociation destructor: m_pRole[B] is NULL already"
+                          << endl;
+        } else {
         delete m_pRole[B];
+                m_pRole[B] = NULL;
+        }
 }
 
@@ -421,5 +433,11 @@ UMLObject* UMLAssociation::getObject(Rol
 
 Uml::IDType UMLAssociation::getObjectId(Role_Type role) {
-        return getObject(role)->getID();
+        UMLObject *o = getObject(role);
+        if (o == NULL) {
+                kdError() << "UMLAssociation::getObjectId(" << role
+                          << "): getObject returns NULL" << endl;
+                return Uml::id_None;
+        }
+        return o->getID();
 }
 






More information about the umbrello-devel mailing list