diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-02-07 09:58:52 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-02-07 18:00:22 +0300 |
commit | 7c62f64682b54fc2eb753c6d393d2c366874ad47 (patch) | |
tree | f0d995f4e39bff68f2027327bf901931a3bc524b /cord | |
parent | 304d734b6e076f1153362789ae5d1caa7c8c8ed5 (diff) | |
download | bdwgc-7c62f64682b54fc2eb753c6d393d2c366874ad47.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.
Diffstat (limited to 'cord')
-rw-r--r-- | cord/cordbscs.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/cord/cordbscs.c b/cord/cordbscs.c index 5fd1e9cc..0f052a76 100644 --- a/cord/cordbscs.c +++ b/cord/cordbscs.c @@ -817,20 +817,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; } } |