gbranden pushed a commit to branch master
in repository groff.

commit 277152bb27731d6672b28a9c51f28ff2cda931b0
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Jul 15 10:46:28 2024 -0500

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

diff --git a/ChangeLog b/ChangeLog
index e367861e9..f8df5c55a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,8 +21,9 @@
        (vunits::to_units, hunits::to_units): Use `ckd_mul()` instead of
        primitive operation, and throw error diagnostic if arithmetic
        wraps.
-       (vunits operator +): Use `ckd_add()` instead of primitive
-       operation, and throw error diagnostic if arithmetic wraps.
+       (vunits operator +, hunits operator +): Use `ckd_add()` 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.
diff --git a/src/roff/troff/hvunits.h b/src/roff/troff/hvunits.h
index 641c46c12..a6f6fb456 100644
--- a/src/roff/troff/hvunits.h
+++ b/src/roff/troff/hvunits.h
@@ -223,7 +223,8 @@ inline hunits operator +(const hunits & x, const hunits & y)
 {
   hunits r;
   r = x;
-  r.n += y.n;
+  if (ckd_add(&r.n, r.n, y.n))
+    error("integer addition wrapped");
   return r;
 }
 

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

Reply via email to