gbranden pushed a commit to branch master
in repository groff.

commit f79d75c0b63fc2498fca1a912583a6c301ecc36d
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Mar 29 18:07:06 2026 -0500

    [groff]: Work on Savannah #68192.
    
    * src/roff/groff/pipeline.c: Check for memory allocation failure, and
      emit a fatal error diagnostic if it occurs.  Unfortunately I was
      unable to test this code, as it's only reachable on non-POSIX systems
      (via `is_system_shell()` and `system_shell_dash_c()`; see
      "src/include/nonposix.h").
    
    Continues the long process of fixing Savannah #68192.
---
 ChangeLog                 | 10 ++++++++++
 src/roff/groff/pipeline.c |  9 ++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index d94a440b8..b089f030e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-03-29  G. Branden Robinson <[email protected]>
+
+       * src/roff/groff/pipeline.c: Check for memory allocation
+       failure, and emit a fatal error diagnostic if it occurs.
+       Unfortunately I was unable to test this code, as it's only
+       reachable on non-POSIX systems (via `is_system_shell()` and
+       `system_shell_dash_c()`; see "src/include/nonposix.h").
+
+       Continues the long process of fixing Savannah #68192.
+
 2026-03-28  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (main): Fix spaces missing from
diff --git a/src/roff/groff/pipeline.c b/src/roff/groff/pipeline.c
index 045edc463..0f58b8d2a 100644
--- a/src/roff/groff/pipeline.c
+++ b/src/roff/groff/pipeline.c
@@ -117,7 +117,14 @@ char *sbasename(const char *path)
   else
     p2 = p1 + strlen(p1);
 
-  base = malloc((size_t)(p2 - p1));
+  char err_str[BUFSIZ];
+  size_t nbytes = (size_t)(p2 - p1);
+  base = malloc(nbytes);
+  if (NULL == base) {
+    sprintf(err_str, "unable to allocate %zd bytes"
+           " for base name of file", nbytes);
+    sys_fatal(err_str);
+  }
   strncpy(base, p1, p2 - p1);
   *(base + (p2 - p1)) = '\0';
 

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

Reply via email to