diff options
author | aaron <> | 2000-04-21 15:27:40 +0000 |
---|---|---|
committer | aaron <> | 2000-04-21 15:27:40 +0000 |
commit | 287002fde6bdd33ca24f49e401ebc5f085a938d6 (patch) | |
tree | 63748cdfb01b7b20df10075b3bec0b16668f9409 | |
parent | 9fb35611cc3d03bef8b690b62e0904507c414a61 (diff) | |
download | openbsd-287002fde6bdd33ca24f49e401ebc5f085a938d6.tar.gz openbsd-287002fde6bdd33ca24f49e401ebc5f085a938d6.tar.bz2 openbsd-287002fde6bdd33ca24f49e401ebc5f085a938d6.zip |
Check return value of strdup(3) for NULL in example code (duh).
-rw-r--r-- | src/lib/libc/string/strdup.3 | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3 index 457b8322cf..2734bf4593 100644 --- a/src/lib/libc/string/strdup.3 +++ b/src/lib/libc/string/strdup.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: strdup.3,v 1.8 2000/04/21 15:24:20 aaron Exp $ | 1 | .\" $OpenBSD: strdup.3,v 1.9 2000/04/21 15:27:40 aaron Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 1990, 1991, 1993 | 3 | .\" Copyright (c) 1990, 1991, 1993 |
4 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" 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 | |||
63 | .Bd -literal -offset indent | 63 | .Bd -literal -offset indent |
64 | char *p; | 64 | char *p; |
65 | 65 | ||
66 | p = strdup("foobar"); | 66 | if ((p = strdup("foobar")) == NULL) { |
67 | fprintf(stderr, "Out of memory.\en"); | ||
68 | exit(1); | ||
69 | } | ||
67 | .Ed | 70 | .Ed |
68 | .Sh SEE ALSO | 71 | .Sh SEE ALSO |
69 | .Xr free 3 , | 72 | .Xr free 3 , |