summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2017-02-15 12:31:57 +0000
committerjsg <jsg@openbsd.org>2017-02-15 12:31:57 +0000
commit7964fb61f5aa481fbc7769d086451e507e689044 (patch)
tree3c351a08e91349b3fb93f4b40bcbe54d00cff6e7 /lib/libc/stdlib/malloc.c
parentDo not clear to end of screen unless the pane is at the bottom. (diff)
downloadwireguard-openbsd-7964fb61f5aa481fbc7769d086451e507e689044.tar.xz
wireguard-openbsd-7964fb61f5aa481fbc7769d086451e507e689044.zip
Add a NULL test to wrterror() to avoid a NULL deref when called from a
free() error path. ok otto@
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r--lib/libc/stdlib/malloc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index adbb1668804..0b071e67438 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malloc.c,v 1.214 2017/02/02 10:35:34 otto Exp $ */
+/* $OpenBSD: malloc.c,v 1.215 2017/02/15 12:31:57 jsg Exp $ */
/*
* Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -278,7 +278,7 @@ wrterror(struct dir_info *d, char *msg, ...)
iov[0].iov_base = pidbuf;
snprintf(pidbuf, sizeof(pidbuf), "%s(%d) in %s(): ", __progname,
- getpid(), d->func ? d->func : "unknown");
+ getpid(), (d != NULL && d->func) ? d->func : "unknown");
iov[0].iov_len = strlen(pidbuf);
iov[1].iov_base = buf;
va_start(ap, msg);