-/* $OpenBSD: rtsock.c,v 1.258 2017/12/13 08:59:02 mpi Exp $ */
+/* $OpenBSD: rtsock.c,v 1.259 2017/12/18 09:40:17 mpi Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
/* if gateway changed remove MPLS information */
if (rt->rt_llinfo != NULL &&
rt->rt_flags & RTF_MPLS) {
- free(rt->rt_llinfo, M_TEMP, 0);
+ free(rt->rt_llinfo, M_TEMP,
+ sizeof(struct rt_mpls));
rt->rt_llinfo = NULL;
rt->rt_flags &= ~RTF_MPLS;
}
/* align message length to the next natural boundary */
len = ALIGN(len);
if (cp == 0 && w != NULL && !second_time) {
- struct walkarg *rw = w;
-
- rw->w_needed += len;
- if (rw->w_needed <= 0 && rw->w_where) {
- if (rw->w_tmemsize < len) {
- free(rw->w_tmem, M_RTABLE, 0);
- rw->w_tmem = malloc(len, M_RTABLE, M_NOWAIT);
- if (rw->w_tmem)
- rw->w_tmemsize = len;
+ w->w_needed += len;
+ if (w->w_needed <= 0 && w->w_where) {
+ if (w->w_tmemsize < len) {
+ free(w->w_tmem, M_RTABLE, w->w_tmemsize);
+ w->w_tmem = malloc(len, M_RTABLE, M_NOWAIT);
+ if (w->w_tmem)
+ w->w_tmemsize = len;
}
- if (rw->w_tmem) {
- cp = rw->w_tmem;
+ if (w->w_tmem) {
+ cp = w->w_tmem;
second_time = 1;
goto again;
} else
- rw->w_where = 0;
+ w->w_where = 0;
}
}
if (cp && w) /* clear the message header */
NET_UNLOCK();
break;
}
- free(w.w_tmem, M_RTABLE, 0);
+ free(w.w_tmem, M_RTABLE, w.w_tmemsize);
w.w_needed += w.w_given;
if (where) {
*given = w.w_where - (caddr_t)where;