[sr-dev] git:master: usrloc(k): safety check for first record in udomain slot

Daniel-Constantin Mierla miconda at gmail.com
Wed Jun 13 16:34:57 CEST 2012


Module: sip-router
Branch: master
Commit: 31f404a98b09b5a6270e860574b16c9f9112c305
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=31f404a98b09b5a6270e860574b16c9f9112c305

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Jun 13 16:33:17 2012 +0200

usrloc(k): safety check for first record in udomain slot

- reported by David Kovarik, FS#234

---

 modules_k/usrloc/udomain.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/modules_k/usrloc/udomain.c b/modules_k/usrloc/udomain.c
index c812e7a..1464c29 100644
--- a/modules_k/usrloc/udomain.c
+++ b/modules_k/usrloc/udomain.c
@@ -1003,14 +1003,16 @@ int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
 		sl = aorhash&(_d->size-1);
 		r = _d->table[sl].first;
 
-		for(i = 0; i < _d->table[sl].n; i++) {
-			if((r->aorhash==aorhash) && (r->aor.len==_aor->len)
-						&& !memcmp(r->aor.s,_aor->s,_aor->len)){
-				*_r = r;
-				return 0;
-			}
+		if(r!=NULL) {
+			for(i = 0; i < _d->table[sl].n; i++) {
+				if((r->aorhash==aorhash) && (r->aor.len==_aor->len)
+							&& !memcmp(r->aor.s,_aor->s,_aor->len)){
+					*_r = r;
+					return 0;
+				}
 
-			r = r->next;
+				r = r->next;
+			}
 		}
 	} else {
 		/* search in DB */




More information about the sr-dev mailing list