summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authorangelos <angelos@openbsd.org>2001-05-14 07:01:37 +0000
committerangelos <angelos@openbsd.org>2001-05-14 07:01:37 +0000
commit5c154e762996198b6cd36c9702e8b09f3931de2d (patch)
treea8f2202e634a541130c0fe2063ae1b3f7c6cf32d /sys/kern/kern_malloc.c
parentM_SYSCTL deraadt@ ok (diff)
downloadwireguard-openbsd-5c154e762996198b6cd36c9702e8b09f3931de2d.tar.xz
wireguard-openbsd-5c154e762996198b6cd36c9702e8b09f3931de2d.zip
Be more paranoid about zapping trailing comma.
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index a479b236d9e..974da0ac31c 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.29 2001/05/14 06:56:30 angelos Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.30 2001/05/14 07:01:37 angelos Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -501,7 +501,9 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen)
for (siz = 0, i = MINBUCKET; i < MINBUCKET + 16; i++)
siz += sprintf(buckstring + siz,
"%d,", (u_int)(1<<i));
- buckstring[siz - 1] = '\0'; /* Remove trailing comma */
+ /* Remove trailing comma */
+ if (siz)
+ buckstring[siz - 1] = '\0';
}
return (sysctl_rdstring(oldp, oldlenp, newp, buckstring));
@@ -536,7 +538,10 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen)
for (siz = 0, i = 0; i < M_LAST; i++)
siz += sprintf(memall + siz, "%s,",
memname[i] ? memname[i] : "");
- memall[siz - 1] = '\0'; /* Remove trailing comma */
+
+ /* Remove trailing comma */
+ if (siz)
+ memall[siz - 1] = '\0';
/* Now, convert all spaces to underscores */
for (i = 0; i < totlen; i++)