gbranden pushed a commit to branch master
in repository groff.
commit 5565799763b22ff9b9f9f27bbb0ac3f9bd76b895
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Jul 15 09:51:19 2024 -0500
[troff]: Fix Savannah #64301 (5/15).
* src/roff/troff/hvunits.h (vunits operator +): Use `ckd_add()` instead
of primitive operation, and throw error diagnostic if arithmetic
wraps.
---
ChangeLog | 2 ++
src/roff/troff/hvunits.h | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 881214b2a..e45d7ebe2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,8 @@
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.
+ (vunits operator +): Use `ckd_add()` 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 a5ccead94..e27f78ff0 100644
--- a/src/roff/troff/hvunits.h
+++ b/src/roff/troff/hvunits.h
@@ -106,7 +106,8 @@ inline vunits operator +(const vunits & x, const vunits & y)
{
vunits 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