gbranden pushed a commit to branch master
in repository groff.

commit d5d4208f7848e84b666e4d7a82086688dbde9627
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Apr 12 01:23:30 2026 -0500

    src/libs/libdriver/printer.cpp: Validate args.
    
    * src/libs/libdriver/printer.cpp (printer::load_font): Validate function
      arguments.  Add assert(3)ion that the string representing of the font
      description to load isn't a null pointer.  If a function argument is
      invalid, return early in `NDEBUG` builds.
---
 ChangeLog                      | 8 ++++++++
 src/libs/libdriver/printer.cpp | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index d6ce2b004..f8cb986d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-04-12  G. Branden Robinson <[email protected]>
+
+       * src/libs/libdriver/printer.cpp (printer::load_font): Validate
+       function arguments.  Add assert(3)ion that the string
+       representing of the font description to load isn't a null
+       pointer.  If a function argument is invalid, return early in
+       `NDEBUG` builds.
+
 2026-04-12  G. Branden Robinson <[email protected]>
 
        * src/libs/libdriver/printer.cpp: Favor idiomatic C++ over C
diff --git a/src/libs/libdriver/printer.cpp b/src/libs/libdriver/printer.cpp
index c65a45e2f..c2dcb8aa1 100644
--- a/src/libs/libdriver/printer.cpp
+++ b/src/libs/libdriver/printer.cpp
@@ -111,6 +111,9 @@ printer::~printer()
 void printer::load_font(int n, const char *nm)
 {
   assert(n >= 0);
+  assert(nm != 0 /* nullptr */);
+  if ((n < 0) || (0 /* nullptr */ == nm))
+      return;
   if (n >= nfonts) {
     if (0 == nfonts) {
       nfonts = 10;

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to