It isn't actually possible to overflow this, but using xreallocarray
gives everyone more peace of mind.
-- 8< --
* src/set-fields.c (set_fields): Prefer xreallocarray which will check
for unlikely overflows when multiplying the number of elements by the
size of the element.
---
src/set-fields.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/set-fields.c b/src/set-fields.c
index 5b3264d35..45f6b0efc 100644
--- a/src/set-fields.c
+++ b/src/set-fields.c
@@ -303,6 +303,6 @@ set_fields (char const *fieldstr, unsigned int options)
Also add a sentinel at the end of RP, to avoid out of bounds access
and for performance reasons. */
++n_frp;
- frp = xrealloc (frp, n_frp * sizeof (struct field_range_pair));
+ frp = xreallocarray (frp, n_frp, sizeof (struct field_range_pair));
frp[n_frp - 1].lo = frp[n_frp - 1].hi = UINTMAX_MAX;
}
--
2.55.0