summaryrefslogtreecommitdiffstats
path: root/lib/libc/string/strdup.3
diff options
context:
space:
mode:
authoraaron <aaron@openbsd.org>2000-04-21 15:27:40 +0000
committeraaron <aaron@openbsd.org>2000-04-21 15:27:40 +0000
commitb43a4a406f295caaf3de23917547a8600576fec8 (patch)
treefad0df9fece888943053f971679a41868a631f53 /lib/libc/string/strdup.3
parentFlesh out libc string function man pages. (diff)
downloadwireguard-openbsd-b43a4a406f295caaf3de23917547a8600576fec8.tar.xz
wireguard-openbsd-b43a4a406f295caaf3de23917547a8600576fec8.zip
Check return value of strdup(3) for NULL in example code (duh).
Diffstat (limited to 'lib/libc/string/strdup.3')
-rw-r--r--lib/libc/string/strdup.37
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/string/strdup.3 b/lib/libc/string/strdup.3
index 457b8322cff..2734bf4593a 100644
--- a/lib/libc/string/strdup.3
+++ b/lib/libc/string/strdup.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: strdup.3,v 1.8 2000/04/21 15:24:20 aaron Exp $
+.\" $OpenBSD: strdup.3,v 1.9 2000/04/21 15:27:40 aaron Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -63,7 +63,10 @@ to an allocated area of memory containing the null-terminated string
.Bd -literal -offset indent
char *p;
-p = strdup("foobar");
+if ((p = strdup("foobar")) == NULL) {
+ fprintf(stderr, "Out of memory.\en");
+ exit(1);
+}
.Ed
.Sh SEE ALSO
.Xr free 3 ,