[sr-dev] git:3.3: usrloc(k): better safety check for null record access

Daniel-Constantin Mierla miconda at gmail.com
Wed Jun 13 17:31:59 CEST 2012


Module: sip-router
Branch: 3.3
Commit: 493612344630a2e0b1f80687c8c650e97801ddf6
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=493612344630a2e0b1f80687c8c650e97801ddf6

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

usrloc(k): better safety check for null record access
(cherry picked from commit 748b79fdeba12736b109dfbd77a3e9bb04c80b97)

---

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

diff --git a/modules_k/usrloc/udomain.c b/modules_k/usrloc/udomain.c
index 1464c29..cf7807e 100644
--- a/modules_k/usrloc/udomain.c
+++ b/modules_k/usrloc/udomain.c
@@ -1003,16 +1003,14 @@ int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
 		sl = aorhash&(_d->size-1);
 		r = _d->table[sl].first;
 
-		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;
+		for(i = 0; r!=NULL && 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;
 		}
 	} else {
 		/* search in DB */




More information about the sr-dev mailing list