gbranden pushed a commit to branch master
in repository groff.
commit 53dc3eed4a5ac4ec9eacb3bc283ec1e6befe33d7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jun 11 10:30:17 2026 -0500
[grolbp]: Slightly refactor.
* src/devices/grolbp/lbp.cpp: Use ISO C++98 exceptions to handle heap
storage allocation failures. Preprocessor-include C++ "<new>" header
file.
(lbp_font::load_lbp_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/grolbp/lbp.cpp | 13 +++++++++++--
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fc4226c6e..f0e73afef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2026-06-11 G. Branden Robinson <[email protected]>
+
+ [grolbp]: Slightly refactor.
+
+ * src/devices/grolbp/lbp.cpp: Use ISO C++98 exceptions to handle
+ heap storage allocation failures. Preprocessor-include C++
+ "<new>" header file.
+ (lbp_font::load_lbp_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]>
* src/preproc/html/pushback.cpp: Migrate to ISO C++98 Boolean
diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp
index acf35baa3..f56d32e1a 100644
--- a/src/devices/grolbp/lbp.cpp
+++ b/src/devices/grolbp/lbp.cpp
@@ -41,6 +41,8 @@ TODO
// GNU extensions to C standard library
#include <getopt.h> // getopt_long()
+#include <new> // std::bad_alloc
+
// operating system services
#include "nonposix.h"
@@ -136,12 +138,19 @@ lbp_font::~lbp_font()
lbp_font *lbp_font::load_lbp_font(const char *s)
{
- lbp_font *f = new lbp_font(s);
+ lbp_font *f = 0 /* nullptr */;
+ try {
+ f = new lbp_font(s);
+ }
+ catch (const std::bad_alloc &e) {
+ fatal("cannot allocate %1 bytes for storage of font description"
+ " for LBP font '%2'", sizeof(lbp_font), s);
+ }
f->lbpname = 0 /* nullptr */;
f->is_scalable = 1; // Default is that fonts are scalable
if (!f->load()) {
delete f;
- return 0;
+ return 0 /* nullptr */;
}
return f;
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit