]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Clear memory allocated by ralloc().
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 4 Sep 2009 09:24:08 +0000 (11:24 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 4 Sep 2009 09:24:08 +0000 (11:24 +0200)
This also fixes bug that timer->recurrent was not cleared
in tm_new() and unexpected recurrence of startup timer
in BGP confused state machine and caused crash.

lib/event.c
lib/mempool.c
lib/resource.c
sysdep/unix/io.c

index 55a9c4872539223ce3ee423f159d015dceb65cc1..d556cd05a13f3feed6ac7ed598243191d2eae2bf 100644 (file)
@@ -63,10 +63,6 @@ event *
 ev_new(pool *p)
 {
   event *e = ralloc(p, &ev_class);
-
-  e->hook = NULL;
-  e->data = NULL;
-  e->n.next = NULL;
   return e;
 }
 
index e6f277b9d6dc99bd590a96e9e2d4cca6d88eea8a..03a6e6ba08ae23efe7ccdfebb96732be60eae3ee 100644 (file)
@@ -64,13 +64,9 @@ linpool
 *lp_new(pool *p, unsigned blk)
 {
   linpool *m = ralloc(p, &lp_class);
-  m->ptr = m->end = NULL;
-  m->first = m->current = NULL;
   m->plast = &m->first;
-  m->first_large = NULL;
   m->chunk_size = blk;
   m->threshold = 3*blk/4;
-  m->total = m->total_large = 0;
   return m;
 }
 
index 8f91450cad4e304f5f33277586b095e8d357d793..a4d8751795a6a93d391c399752504dddfc4e4d33 100644 (file)
@@ -183,13 +183,14 @@ rdump(void *res)
  *
  * This function is called by the resource classes to create a new
  * resource of the specified class and link it to the given pool.
- * Size of the resource structure is taken from the @size field
- * of the &resclass.
+ * Allocated memory is zeroed. Size of the resource structure is taken
+ * from the @size field of the &resclass.
  */
 void *
 ralloc(pool *p, struct resclass *c)
 {
   resource *r = xmalloc(c->size);
+  bzero(r, c->size);
 
   r->class = c;
   add_tail(&p->inside, &r->n);
index a5e0522255255c5c6d9a143aba5c67b4e75d4370..99d33936d33a83cbe1daff23f58eb7f81da57e2d 100644 (file)
@@ -205,10 +205,6 @@ timer *
 tm_new(pool *p)
 {
   timer *t = ralloc(p, &tm_class);
-  t->hook = NULL;
-  t->data = NULL;
-  t->randomize = 0;
-  t->expires = 0;
   return t;
 }
 
@@ -595,22 +591,9 @@ sk_new(pool *p)
 {
   sock *s = ralloc(p, &sk_class);
   s->pool = p;
-  s->data = NULL;
-  s->saddr = s->daddr = IPA_NONE;
-  s->sport = s->dport = 0;
+  // s->saddr = s->daddr = IPA_NONE;
   s->tos = s->ttl = -1;
-  s->flags = 0;
-  s->iface = NULL;
-  s->rbuf = NULL;
-  s->rx_hook = NULL;
-  s->rbsize = 0;
-  s->tbuf = NULL;
-  s->tx_hook = NULL;
-  s->tbsize = 0;
-  s->err_hook = NULL;
   s->fd = -1;
-  s->rbuf_alloc = s->tbuf_alloc = NULL;
-  s->password = NULL;
   return s;
 }