Update of bug #68796 (group groff):

         Planned Release:                    None => 1.25.0
                 Summary: [troff] assertion failure when `defcolor` request
given invalid color identifier => [PATCH] [troff] assertion failure when
`defcolor` request given invalid color identifier

    _______________________________________________________

Follow-up Comment #2:


commit 6e32c4d78e55284a1bab36e8349de7d3bb43cc84
Author: G. Branden Robinson <[email protected]>
Date:   Sun Oct 18 20:50:31 2026 -0500

    XXX [troff]: Fix Savannah #68796.
    
    * src/roff/troff/input.cpp (define_color): Improve `defcolor` request
      argument validation.  Replace assert(3)ion that could be tripped by
      invalid characters in color identifier with skip of input line.  Throw
      warnings in category "missing" if second or third arguments are
      absent.

diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 8c8d44005..9258a0738 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1694,8 +1694,17 @@ static void define_color() // .defcolor
     return;
   }
   symbol color_name = read_long_identifier();
-  // Testing has_arg() should have ensured this.
-  assert(color_name != 0 /* nullptr */);
+  if (color_name.is_null()) {
+    // The identifier was garbage, like `a\&b`.
+    skip_line();
+    return;
+  }
+  if (!has_arg()) {
+    warning(WARN_MISSING, "color definition request"
+           " expects color space and channel value arguments");
+    skip_line();
+    return;
+  }
   if (color_name == default_symbol) {
     warning(WARN_COLOR, "default color cannot be redefined");
     skip_line();
@@ -1703,8 +1712,13 @@ static void define_color() // .defcolor
   }
   symbol color_space = read_long_identifier();
   if (color_space.is_null()) {
-    warning(WARN_MISSING, "missing color space in color definition"
-           " request");
+    // The identifier was garbage, like `a\&b`.
+    skip_line();
+    return;
+  }
+  if (!has_arg()) {
+    warning(WARN_MISSING, "color definition request"
+           " expects color channel value argument(s)");
     skip_line();
     return;
   }




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68796>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to