Browse Source

Check for null pointer prior to modifying the ref count.

Sascha Zelzer 13 years ago
parent
commit
2813ae2c15
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Libs/PluginFramework/ctkServiceRegistration.cpp

+ 2 - 2
Libs/PluginFramework/ctkServiceRegistration.cpp

@@ -51,7 +51,7 @@ ctkServiceRegistration::ctkServiceRegistration(const ctkServiceRegistration& reg
 ctkServiceRegistration::ctkServiceRegistration(ctkServiceRegistrationPrivate* registrationPrivate)
   : d_ptr(registrationPrivate)
 {
-  d_func()->ref.ref();
+  if(d_func()) d_func()->ref.ref();
 }
 
 //----------------------------------------------------------------------------
@@ -228,7 +228,7 @@ ctkServiceRegistration& ctkServiceRegistration::operator=(const ctkServiceRegist
 {
   ctkServiceRegistrationPrivate* curr_d = d_func();
   d_ptr = registration.d_ptr;
-  d_ptr->ref.ref();
+  if (d_ptr) d_ptr->ref.ref();
 
   if (curr_d && !curr_d->ref.deref())
     delete curr_d;