From: brynet Date: Thu, 13 Apr 2017 18:36:51 +0000 (+0000) Subject: Use recallocarray in getdelim/getline to clear memory on buffer resizes, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fa826e3f7e01ed0795ae97fd2c6c675f1be3392d;p=openbsd Use recallocarray in getdelim/getline to clear memory on buffer resizes, inspired by a similar change to fgetln. ok deraadt millert --- 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;