--- a/lib/bitmap.c~bitmap-fix-bitmap_cut-for-partial-overlapping-case +++ a/lib/bitmap.c @@ -212,13 +212,13 @@ void bitmap_cut(unsigned long *dst, cons unsigned long keep = 0, carry; int i; - memmove(dst, src, len * sizeof(*dst)); - if (first % BITS_PER_LONG) { keep = src[first / BITS_PER_LONG] & (~0UL >> (BITS_PER_LONG - first % BITS_PER_LONG)); } + memmove(dst, src, len * sizeof(*dst)); + while (cut--) { for (i = first / BITS_PER_LONG; i < len; i++) { if (i < len - 1)