Explorar o código

ims_*_scscf: Safety checks for the locks

Carsten Bock %!s(int64=10) %!d(string=hai) anos
pai
achega
451fbec281
Modificáronse 2 ficheiros con 17 adicións e 3 borrados
  1. 8 1
      modules/ims_usrloc_scscf/bin_utils.c
  2. 9 2
      modules/ims_usrloc_scscf/ucontact.c

+ 8 - 1
modules/ims_usrloc_scscf/bin_utils.c

@@ -898,7 +898,14 @@ ims_subscription *bin_decode_ims_subscription(bin_data *x)
 		if (!bin_decode_service_profile(x,imss->service_profiles+i)) goto error;
 
 	imss->lock = lock_alloc();
-	imss->lock = lock_init(imss->lock);
+	if (imss->lock==0){
+		goto error;
+	}
+	if (lock_init(imss->lock)==0){
+		lock_dealloc(imss->lock);
+		imss->lock=0;
+		goto error;
+	}
 	imss->ref_count = 1;
 
 	return imss;

+ 9 - 2
modules/ims_usrloc_scscf/ucontact.c

@@ -93,7 +93,14 @@ ucontact_t* new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _
     memset(c, 0, sizeof (ucontact_t));
     
     c->lock = lock_alloc();
-    c->lock = lock_init(c->lock);
+    if (c->lock==0){
+        goto error;
+    }
+    if (lock_init(c->lock)==0){
+	lock_dealloc(c->lock);
+	c->lock=0;
+	goto error;
+    }
 
     //setup callback list
     c->cbs = (struct ulcb_head_list*) shm_malloc(sizeof (struct ulcb_head_list));
@@ -527,4 +534,4 @@ void release_ucontact(struct ucontact* _c) {
     lock_contact_slot_i(_c->contact_hash);
     _c->ref_count--;
     unlock_contact_slot_i(_c->contact_hash);
-}
+}