summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBryan Steele <brynet@cvs.openbsd.org>2017-04-13 18:36:52 +0000
committerBryan Steele <brynet@cvs.openbsd.org>2017-04-13 18:36:52 +0000
commit451e362b97e14e01292d3f4a4d6466337b452452 (patch)
tree5bb4bdbc58a7f834ecb125c0727ddc116d933e80 /lib
parent8856e9ac6c766efb92e9eefe745c88d8f0fe38c9 (diff)
Use recallocarray in getdelim/getline to clear memory on buffer resizes,
inspired by a similar change to fgetln. ok deraadt millert
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdio/getdelim.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdio/getdelim.c b/lib/libc/stdio/getdelim.c
index 0e0e338328c..d709a3d18e1 100644
--- a/lib/libc/stdio/getdelim.c
+++ b/lib/libc/stdio/getdelim.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getdelim.c,v 1.5 2016/09/21 04:38:56 guenther Exp $ */
+/* $OpenBSD: getdelim.c,v 1.6 2017/04/13 18:36:51 brynet Exp $ */
/* $NetBSD: getdelim.c,v 1.13 2011/07/22 23:12:30 joerg Exp $ */
/*
@@ -103,7 +103,7 @@ getdelim(char **__restrict buf, size_t *__restrict buflen,
newlen++;
}
- newb = realloc(*buf, newlen);
+ newb = recallocarray(*buf, *buflen, newlen, 1);
if (newb == NULL)
goto error;
*buf = newb;