gbranden pushed a commit to branch master
in repository groff.

commit aeab6012b4307af88decbc6f85b444988955072a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Jul 4 19:57:30 2026 -0500

    [groff]: Migrate to ISO C++98 `try/new/catch`.
    
    * src/roff/groff/groff.cpp (possible_command::build_argv): Use ISO C++98
      exceptions to handle heap storage allocation failure.  Preprocessor-
      include C++ "<new>" header file.
    
    Continues the long process of fixing Savannah #68192.
---
 ChangeLog                |  8 ++++++++
 src/roff/groff/groff.cpp | 11 ++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 472562313..e5f3ae1f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-07-04  G. Branden Robinson <[email protected]>
+
+       * src/roff/groff/groff.cpp (possible_command::build_argv): Use
+       ISO C++98 exceptions to handle heap storage allocation failure.
+       Preprocessor-include C++ "<new>" header file.
+
+       Continues the long process of fixing Savannah #68192.
+
 2026-07-04  G. Branden Robinson <[email protected]>
 
        * src/roff/groff/groff.cpp (possible_command::build_argv): Fix
diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp
index 04bfeb665..45ae102d9 100644
--- a/src/roff/groff/groff.cpp
+++ b/src/roff/groff/groff.cpp
@@ -38,6 +38,9 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include <sys/types.h> // pid_t
 #include <signal.h> // kill()
 
+#include <new> // std::bad_alloc
+
+// operating system services
 // needed for close(), dup(), execvp(), _exit(), fork(), pipe(), wait()
 #include "posix.h"
 #include "nonposix.h"
@@ -738,7 +741,13 @@ void possible_command::build_argv()
   }
   // Build an argument vector.
   const size_t argv_len = argc + 1;
-  argv = new char *[argv_len];
+  try {
+    argv = new char *[argv_len];
+  }
+  catch (const std::bad_alloc &exc) {
+    fatal("cannot allocate %1 bytes for argument storage",
+         (argv_len * sizeof(char *)));
+  }
   argv[0] = name;
   for (size_t i = 1; i < argc; i++) {
     argv[i] = p;

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

Reply via email to