diff options
author | 2004-08-20 18:17:35 +0000 | |
---|---|---|
committer | 2004-08-20 18:17:35 +0000 | |
commit | b3a3de1f76ebd6077368215a9c7f1be06540d8b0 (patch) | |
tree | 43f3bc6c2632eacde6880cce381c1d7a7a1d9015 /lib/libc | |
parent | This is VERY MUCH work in progress. However it is a first cut of notes (diff) | |
download | wireguard-openbsd-b3a3de1f76ebd6077368215a9c7f1be06540d8b0.tar.xz wireguard-openbsd-b3a3de1f76ebd6077368215a9c7f1be06540d8b0.zip |
Don't need to check lbuf != NULL when free()ing it. In addition,
since the EOF w/o EOL can only happen for the last line, move the
free() outside the loop so we only do it once. OK otto@
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/stdio/fgetln.3 | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/libc/stdio/fgetln.3 b/lib/libc/stdio/fgetln.3 index 18e2d038168..78a96dc6ed4 100644 --- a/lib/libc/stdio/fgetln.3 +++ b/lib/libc/stdio/fgetln.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fgetln.3,v 1.10 2003/06/02 20:18:37 millert Exp $ +.\" $OpenBSD: fgetln.3,v 1.11 2004/08/20 18:17:35 millert Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -133,6 +133,7 @@ temporary buffer: if (buf[len - 1] == '\en') buf[len - 1] = '\e0'; else { + /* EOF without EOL, copy and add the NUL */ if ((lbuf = (char *)malloc(len + 1)) == NULL) err(1, NULL); memcpy(lbuf, buf, len); @@ -140,10 +141,6 @@ temporary buffer: buf = lbuf; } printf("%s\en", buf); - - if (lbuf != NULL) { - free(lbuf); - lbuf = NULL; - } } + free(lbuf); .Ed |