summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-02-07 09:58:52 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-02-22 09:05:00 +0300
commitcb54e978347243af964b8b6f3a97f19b02f8904a (patch)
treee5c35731cb82ffa4c2bac0d471007d4f12fe0622
parent3e7cd5d95f2f84c034a1bc54be09852aae3c9392 (diff)
downloadbdwgc-cb54e978347243af964b8b6f3a97f19b02f8904a.tar.gz
Eliminate stringop-overflow gcc-12 warning in CORD__next
* cord/cordbscs.c (CORD__next): Reduce limit and i values by cur_pos; add cur_pos to i when fn() is called; add cur_pos to limit in cur_end assignment.
-rw-r--r--cord/cordbscs.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/cord/cordbscs.c b/cord/cordbscs.c
index 1b4ec28b..f2a5a505 100644
--- a/cord/cordbscs.c
+++ b/cord/cordbscs.c
@@ -816,20 +816,20 @@ void CORD__next(CORD_pos p)
if (cur_pos < end_pos) {
/* Fill cache and return. */
size_t i;
- size_t limit = cur_pos + FUNCTION_BUF_SZ;
+ size_t limit = FUNCTION_BUF_SZ;
CORD_fn fn = f -> fn;
void * client_data = f -> client_data;
- if (limit > end_pos) {
- limit = end_pos;
+ if (end_pos - cur_pos < FUNCTION_BUF_SZ) {
+ limit = end_pos - cur_pos;
}
- for (i = cur_pos; i < limit; i++) {
- p[0].function_buf[i - cur_pos] =
- (*fn)(i - start_pos, client_data);
+ for (i = 0; i < limit; i++) {
+ p[0].function_buf[i] = (*fn)(i + cur_pos - start_pos,
+ client_data);
}
p[0].cur_start = cur_pos;
p[0].cur_leaf = p[0].function_buf;
- p[0].cur_end = limit;
+ p[0].cur_end = cur_pos + limit;
return;
}
}