summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-12-18 09:40:18 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-12-18 09:40:18 +0000
commit004c0017be51c5bbf575806db7dbc387c63fa5ca (patch)
tree0dd1df575da6bcd790a156f99feba1317be1a9b4 /sys/net
parent09d1c0e3308097ad0e761258840abcf7c0d03146 (diff)
Size for free(9).
From <kshe59 at zoho.eu>
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/rtsock.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index c3d1f6db108..6a516bf00cd 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $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 $ */
/*
@@ -980,7 +980,8 @@ change:
/* 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;
}
@@ -1363,22 +1364,20 @@ again:
/* 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 */
@@ -1809,7 +1808,7 @@ sysctl_rtable(int *name, u_int namelen, void *where, size_t *given, void *new,
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;