gbranden pushed a commit to branch master
in repository groff.
commit 31e8ed9a968d24183402249ac7df89077ff767bf
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Mar 15 11:53:23 2026 -0500
src/devices/grops/psrm.cpp: Handle getenv failure.
* src/devices/grops/psrm.cpp (resource_manager::output_prolog): Handle
getenv(3) failure. Having just written successfully to the process
environment (else we `fatal()`ed out), assert(3) that reading back the
same environment variable with getenv(3) returned a non-null pointer.
If it didn't and `NDEBUG` is defined, `fatal()` out in this case too.
---
ChangeLog | 9 +++++++++
src/devices/grops/psrm.cpp | 3 +++
2 files changed, 12 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 4cf270d45..b4169536f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-03-15 G. Branden Robinson <[email protected]>
+
+ * src/devices/grops/psrm.cpp (resource_manager::output_prolog):
+ Handle getenv(3) failure. Having just written successfully to
+ the process environment (else we `fatal()`ed out), assert(3)
+ that reading back the same environment variable with getenv(3)
+ returned a non-null pointer. If it didn't and `NDEBUG` is
+ defined, `fatal()` out in this case too.
+
2026-03-15 G. Branden Robinson <[email protected]>
* src/devices/xditview/device.c: Slightly refactor. Convert
diff --git a/src/devices/grops/psrm.cpp b/src/devices/grops/psrm.cpp
index 078443904..4ab30b765 100644
--- a/src/devices/grops/psrm.cpp
+++ b/src/devices/grops/psrm.cpp
@@ -299,6 +299,9 @@ void resource_manager::output_prolog(ps_output &out)
fatal("cannot update process environment: %1", strerror(errno));
}
char *prologue = getenv("GROPS_PROLOGUE");
+ assert(prologue != 0 /* nullptr */);
+ if (0 /* nullptr */ == prologue)
+ fatal("cannot access process environment: %1", strerror(errno));
FILE *fp = font::open_resource_file(prologue, &path);
if (0 /* nullptr */ == fp)
fatal("cannot open PostScript prologue file '%1': %2", prologue,
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit