From fa826e3f7e01ed0795ae97fd2c6c675f1be3392d Mon Sep 17 00:00:00 2001 From: brynet Date: Thu, 13 Apr 2017 18:36:51 +0000 Subject: [PATCH] Use recallocarray in getdelim/getline to clear memory on buffer resizes, inspired by a similar change to fgetln. ok deraadt millert --- lib/libc/stdio/getdelim.c | 4 ++-- 1 file 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; -- 2.20.1