gbranden pushed a commit to branch master
in repository groff.

commit ba57af884546e75fa28c6769abfd4d2fd286f27b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Jul 15 10:07:51 2024 -0500

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

diff --git a/ChangeLog b/ChangeLog
index 6639e6797..684dbb5f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,8 +22,9 @@
        wraps.
        (vunits operator +): Use `ckd_add()` instead of primitive
        operation, and throw error diagnostic if arithmetic wraps.
-       (vunits operator *): Use `ckd_mul()` instead of primitive
-       operation, and throw error diagnostic if arithmetic wraps.
+       (vunits operator *, hunits operator *): 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 7f3feb35c..1dde42c02 100644
--- a/src/roff/troff/hvunits.h
+++ b/src/roff/troff/hvunits.h
@@ -260,7 +260,8 @@ inline hunits operator *(const hunits & x, int n)
 {
   hunits r;
   r = x;
-  r.n *= n;
+  if (ckd_mul(&r.n, x.n, n))
+    error("integer multiplication wrapped");
   return r;
 }
 
@@ -268,7 +269,8 @@ inline hunits operator *(int n, const hunits & x)
 {
   hunits r;
   r = x;
-  r.n *= n;
+  if (ckd_mul(&r.n, x.n, n))
+    error("integer multiplication wrapped");
   return r;
 }
 

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

Reply via email to