diff options
author | Aaron Campbell <aaron@cvs.openbsd.org> | 1999-09-21 01:47:09 +0000 |
---|---|---|
committer | Aaron Campbell <aaron@cvs.openbsd.org> | 1999-09-21 01:47:09 +0000 |
commit | f23d205f6e57742341a906ae3ed6719b43ebe0c4 (patch) | |
tree | 9c186317d73d200bee89fae0ee310c491cac27d6 /lib/libc | |
parent | c1dafb5b8fca1e6d218361e8a43644a79cf3e768 (diff) |
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.3 | 5 |
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; |