From 3e1f9cb3b38e68d3e273a0e37c372f158ed0c17c Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 16 Feb 2020 02:57:25 +0000 Subject: pm_getline - return correct buffer size git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3738 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- lib/pmfileio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pmfileio.c b/lib/pmfileio.c index bfb0d117..bea01abe 100644 --- a/lib/pmfileio.c +++ b/lib/pmfileio.c @@ -908,11 +908,12 @@ pm_getline(FILE * const ifP, } if (gotLine) { - REALLOCARRAY(buffer, nReadSoFar+1); + bufferSz = nReadSoFar + 1; + REALLOCARRAY(buffer, bufferSz); if (!buffer) { pm_error("Failed to allocate %lu bytes for buffer " "to assemble a line of input", - (unsigned long) nReadSoFar+1); + (unsigned long) bufferSz); } buffer[nReadSoFar] = '\0'; } -- cgit 1.4.1