Module: kamailio
Branch: master
Commit: 451fbec2819e8e32450c44eff7e76cbbf3d81abe
URL:
https://github.com/kamailio/kamailio/commit/451fbec2819e8e32450c44eff7e76cb…
Author: Carsten Bock <carsten(a)ng-voice.com>
Committer: Carsten Bock <carsten(a)ng-voice.com>
Date: 2015-05-05T22:01:36+02:00
ims_*_scscf: Safety checks for the locks
---
Modified: modules/ims_usrloc_scscf/bin_utils.c
Modified: modules/ims_usrloc_scscf/ucontact.c
---
Diff:
https://github.com/kamailio/kamailio/commit/451fbec2819e8e32450c44eff7e76cb…
Patch:
https://github.com/kamailio/kamailio/commit/451fbec2819e8e32450c44eff7e76cb…
---
diff --git a/modules/ims_usrloc_scscf/bin_utils.c b/modules/ims_usrloc_scscf/bin_utils.c
index 958dc26..0588380 100644
--- a/modules/ims_usrloc_scscf/bin_utils.c
+++ b/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;
diff --git a/modules/ims_usrloc_scscf/ucontact.c b/modules/ims_usrloc_scscf/ucontact.c
index 7ea2667..c0a2ef5 100644
--- a/modules/ims_usrloc_scscf/ucontact.c
+++ b/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);
-}
\ No newline at end of file
+}