gbranden pushed a commit to branch master
in repository groff.

commit 4d90e3b1097c98c39b3b778384d255af69014709
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Jul 15 09:49:57 2024 -0500

    [troff]: Fix Savannah #64301 (4/15).
    
    * src/roff/troff/hvunits.h (vunits::to_units): Use `ckd_mul()` instead
      of primitive operation, and throw error diagnostic if arithmetic
      wraps.
---
 ChangeLog                | 2 ++
 src/roff/troff/hvunits.h | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 02e2aaaa0..881214b2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@
        headers.
        (vunits operator -): Use `ckd_sub()` instead of primitive
        operation, and throw error diagnostic if arithmetic wraps.
+       (vunits::to_units): Use `ckd_mul()` instead of primitive
+       operation, and throw error diagnostic if arithmetic wraps.
 
 2024-07-18  G. Branden Robinson <[email protected]>
 
diff --git a/src/roff/troff/hvunits.h b/src/roff/troff/hvunits.h
index c8b56587b..a5ccead94 100644
--- a/src/roff/troff/hvunits.h
+++ b/src/roff/troff/hvunits.h
@@ -91,7 +91,10 @@ inline vunits:: vunits() : n(0)
 
 inline units vunits::to_units()
 {
-  return n * vresolution;
+  units r;
+  if (ckd_mul(&r, n, vresolution))
+    error("integer multiplication wrapped");
+  return r;
 }
 
 inline bool vunits::is_zero()

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

Reply via email to