gbranden pushed a commit to branch master
in repository groff.
commit 6d50caa970740f14d3c837c4dd58eeefede7ab62
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon May 25 01:14:39 2026 -0500
[grodvi]: Slightly refactor.
* src/devices/grodvi/dvi.cpp: Use ISO C++98 exceptions to handle heap
storage allocation failures. Preprocessor-include C++ "<new>" header
file.
(dvi_font::load_dvi_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/grodvi/dvi.cpp | 11 ++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 51c9a0a45..45c515c3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2026-05-25 G. Branden Robinson <[email protected]>
+
+ [grodvi]: Slightly refactor.
+
+ * src/devices/grodvi/dvi.cpp: Use ISO C++98 exceptions to handle
+ heap storage allocation failures. Preprocessor-include C++
+ "<new>" header file.
+ (dvi_font::load_dvi_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-05-25 G. Branden Robinson <[email protected]>
[libgroff]: Extend argument printer for diagnostic messages to
diff --git a/src/devices/grodvi/dvi.cpp b/src/devices/grodvi/dvi.cpp
index 348fa9501..e2b92c7ca 100644
--- a/src/devices/grodvi/dvi.cpp
+++ b/src/devices/grodvi/dvi.cpp
@@ -33,6 +33,8 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
// GNU extensions to C standard library
#include <getopt.h> // getopt_long()
+#include <new> // std::bad_alloc
+
// operating system services
#include "nonposix.h"
@@ -86,7 +88,14 @@ public:
dvi_font *dvi_font::load_dvi_font(const char *s)
{
- dvi_font *f = new dvi_font(s);
+ dvi_font *f = 0 /* nullptr */;
+ try {
+ f = new dvi_font(s);
+ }
+ catch (const std::bad_alloc &e) {
+ fatal("cannot allocate %1 bytes for storage of font description"
+ " for DVI font '%2'", sizeof(dvi_font), s);
+ }
if (!f->load()) {
delete f;
return 0 /* nullptr */;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit