usrloc(k): safety check for first record in udomain slot
authorDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 13 Jun 2012 14:33:17 +0000 (16:33 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 13 Jun 2012 14:34:39 +0000 (16:34 +0200)
- reported by David Kovarik, FS#234

modules_k/usrloc/udomain.c

index c812e7a..1464c29 100644 (file)
@@ -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 */