gbranden pushed a commit to branch master
in repository groff.

commit 60d21df23c68cff59e3e823d5da0938a532dbd48
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Dec 10 16:00:25 2025 -0600

    [troff]: Fix apparent memory leak.
    
    * src/roff/troff/input.cpp (read_input_until_terminator): Fix apparent
      memory leak.  The heap-allocated memory we allocate to back the local
      `buf` was not being freed on an error path out of the function.
---
 ChangeLog                | 7 +++++++
 src/roff/troff/input.cpp | 1 +
 2 files changed, 8 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 7080f3850..673a70800 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-12-10  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (read_input_until_terminator): Fix
+       apparent memory leak.  The heap-allocated memory we allocate to
+       back the local `buf` was not being freed on an error path out of
+       the function.
+
 2025-12-08  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp: Trivially refactor.  Rename
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 659850bfa..796d7386f 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -3183,6 +3183,7 @@ static symbol read_input_until_terminator(bool required,
   }
   if (0 == i) {
     diagnose_missing_identifier(required);
+    delete[] buf;
     return NULL_SYMBOL;
   }
   if ((end_char != 0U) && (buf[i] == end_char))

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to