[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 17/25: [troff]: Fix Savannah #64301 (8/15).
From: |
G. Branden Robinson |
Subject: |
[groff] 17/25: [troff]: Fix Savannah #64301 (8/15). |
Date: |
Fri, 19 Jul 2024 15:12:43 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 870f3a6e69b51eec85bb8383002b6134fec2dd83
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jul 15 10:21:16 2024 -0500
[troff]: Fix Savannah #64301 (8/15).
* src/roff/troff/hvunits.h (hunits::to_units): Use `ckd_mul()` instead
of primitive operation, and throw error diagnostic if arithmetic
wraps.
---
ChangeLog | 5 +++--
src/roff/troff/hvunits.h | 5 ++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 59e11fa41..6639e6797 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,8 +17,9 @@
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.
+ (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 *): Use `ckd_mul()` instead of primitive
diff --git a/src/roff/troff/hvunits.h b/src/roff/troff/hvunits.h
index f0590fd9e..7f3feb35c 100644
--- a/src/roff/troff/hvunits.h
+++ b/src/roff/troff/hvunits.h
@@ -208,7 +208,10 @@ inline hunits:: hunits() : n(0)
inline units hunits::to_units()
{
- return n * hresolution;
+ units r;
+ if (ckd_mul(&r, n, hresolution))
+ error("integer multiplication wrapped");
+ return r;
}
inline bool hunits::is_zero()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 17/25: [troff]: Fix Savannah #64301 (8/15).,
G. Branden Robinson <=