copy: safeguard underflow

This commit is contained in:
Thomas Schoebel-Theuer 2021-04-16 11:23:17 +02:00
parent 8412411390
commit 344c3a7e95
1 changed files with 2 additions and 1 deletions

View File

@ -750,7 +750,8 @@ int _run_copy(struct copy_brick *brick, loff_t this_start)
prev = -1; prev = -1;
if (this_start > brick->copy_last) { if (this_start > brick->copy_last) {
prev = GET_INDEX(this_start - COPY_CHUNK); if (this_start >= COPY_CHUNK)
prev = GET_INDEX(this_start - COPY_CHUNK);
max -= (this_start - brick->copy_last) / COPY_CHUNK; max -= (this_start - brick->copy_last) / COPY_CHUNK;
all_max = max; all_max = max;
} }