소스 검색

Check for null pointer prior to modifying the ref count.

Sascha Zelzer 13 년 전
부모
커밋
2813ae2c15
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  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;