usrloc(k): better safety check for null record access
authorDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 13 Jun 2012 15:29:51 +0000 (17:29 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 13 Jun 2012 15:29:51 +0000 (17:29 +0200)
modules_k/usrloc/udomain.c

index 1464c29..cf7807e 100644 (file)
@@ -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;
 
                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 */
                }
        } else {
                /* search in DB */