about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/pmfileio.c5
1 files changed, 3 insertions, 2 deletions
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';
     }