gbranden pushed a commit to branch master
in repository groff.
commit e493a4b1752004273d41dc1b1a760ce528a82d2d
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jun 11 10:33:05 2026 -0500
[grolj4]: Slightly refactor.
* src/devices/grolj4/lj4.cpp: Use ISO C++98 exceptions to handle heap
storage allocation failures. Preprocessor-include C++ "<new>" header
file.
(lj4_font::load_lj4_font): Catch `std:bad_alloc` exception and
`fatal()` out with an attempt to describe what we were doing.
Continues the long process of fixing Savannah #68192.
---
ChangeLog | 12 ++++++++++++
src/devices/grolj4/lj4.cpp | 11 ++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index f0e73afef..c920b3d72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2026-06-11 G. Branden Robinson <[email protected]>
+
+ [grolj4]: Slightly refactor.
+
+ * src/devices/grolj4/lj4.cpp: Use ISO C++98 exceptions to handle
+ heap storage allocation failures. Preprocessor-include C++
+ "<new>" header file.
+ (lj4_font::load_lj4_font): Catch `std:bad_alloc` exception and
+ `fatal()` out with an attempt to describe what we were doing.
+
+ Continues the long process of fixing Savannah #68192.
+
2026-06-11 G. Branden Robinson <[email protected]>
[grolbp]: Slightly refactor.
diff --git a/src/devices/grolj4/lj4.cpp b/src/devices/grolj4/lj4.cpp
index f45f5867b..fb7d68d06 100644
--- a/src/devices/grolj4/lj4.cpp
+++ b/src/devices/grolj4/lj4.cpp
@@ -49,6 +49,8 @@ X command to include bitmap graphics
// GNU extensions to C standard library
#include <getopt.h> // getopt_long()
+#include <new> // std::bad_alloc
+
// operating system services
#include "nonposix.h"
@@ -131,7 +133,14 @@ lj4_font::~lj4_font()
lj4_font *lj4_font::load_lj4_font(const char *s)
{
- lj4_font *f = new lj4_font(s);
+ lj4_font *f = 0 /* nullptr */;
+ try {
+ f = new lj4_font(s);
+ }
+ catch (const std::bad_alloc &e) {
+ fatal("cannot allocate %1 bytes for storage of font description"
+ " for LJ4 font '%2'", sizeof(lj4_font), s);
+ }
if (!f->load()) {
delete f;
return 0 /* nullptr */;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit