summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authoraaron <aaron@openbsd.org>1999-09-21 01:47:08 +0000
committeraaron <aaron@openbsd.org>1999-09-21 01:47:08 +0000
commit52e3fac0a44b6b2c1385dc1a581a54a2b4a8ebd2 (patch)
tree63517f6812b2f6cc4bf23c0c27851098f5954f07 /lib/libc
parentTypo fix (invalud -> invalid); mason@netbsd.org (diff)
downloadwireguard-openbsd-52e3fac0a44b6b2c1385dc1a581a54a2b4a8ebd2.tar.xz
wireguard-openbsd-52e3fac0a44b6b2c1385dc1a581a54a2b4a8ebd2.zip
It's a good idea to check the return value of malloc() in example code.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdio/fgetln.35
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/stdio/fgetln.3 b/lib/libc/stdio/fgetln.3
index c1298d11617..20f16a26b48 100644
--- a/lib/libc/stdio/fgetln.3
+++ b/lib/libc/stdio/fgetln.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: fgetln.3,v 1.5 1999/09/15 21:26:58 aaron Exp $
+.\" $OpenBSD: fgetln.3,v 1.6 1999/09/21 01:47:08 aaron Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -128,7 +128,8 @@ temporary buffer:
if (buf[len - 1] == '\en')
buf[len - 1] = '\e0';
else {
- lbuf = (char *)malloc(len + 1);
+ if ((lbuf = (char *)malloc(len + 1)) == NULL)
+ err(1, NULL);
memcpy(lbuf, buf, len);
lbuf[len] = '\e0';
buf = lbuf;