gbranden pushed a commit to branch master
in repository groff.
commit b0ddddde568d2187ce5958076fe5f499adb8b494
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Oct 1 01:19:25 2026 -0500
[hpftodit]: Migrate to ISO C++98 `try/new/catch`.
...some more.
* src/utils/hpftodit/hpftodit.cpp (output_font_name): Use ISO C++98
exceptions to handle heap storage allocation failure, catching
`std::bad_alloc`.
Continues the long process of fixing Savannah #68192.
---
ChangeLog | 8 ++++++++
src/utils/hpftodit/hpftodit.cpp | 9 ++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index c19945b7a..c8538b784 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-10-01 G. Branden Robinson <[email protected]>
+
+ * src/utils/hpftodit/hpftodit.cpp (output_font_name): Use ISO
+ C++98 exceptions to handle heap storage allocation failure,
+ catching `std::bad_alloc`.
+
+ Continues the long process of fixing Savannah #68192.
+
2026-09-30 G. Branden Robinson <[email protected]>
* src/utils/hpftodit/hpftodit.cpp (output_font_name): Heavily
diff --git a/src/utils/hpftodit/hpftodit.cpp b/src/utils/hpftodit/hpftodit.cpp
index 1f3ddb10d..2100a234f 100644
--- a/src/utils/hpftodit/hpftodit.cpp
+++ b/src/utils/hpftodit/hpftodit.cpp
@@ -610,8 +610,15 @@ output_font_name(File &f)
fatal("TFM file claims oversized font name length of %1", count);
// The font name may be fixed-width, but our string isn't.
size_t font_name_size = count + 1 /* '\0' */;
+ char *font_name = 0 /* nullptr */;
// C++03: new char[count]();
- char *font_name = new char[font_name_size];
+ try {
+ font_name = new char[font_name_size];
+ }
+ catch (const std::bad_alloc &e) {
+ fatal("cannot allocate %1 bytes to store font name",
+ font_name_size);
+ }
(void) memset(font_name, 0, font_name_size * sizeof(char));
if (count > 4) { // value is a file offset to the string
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit