浏览代码

hashindex_compact: use memmove for possibly overlapping copy

Marian Beermann 8 年之前
父节点
当前提交
1d5d50463c
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/borg/_hashindex.c

+ 2 - 1
src/borg/_hashindex.c

@@ -650,7 +650,8 @@ hashindex_compact(HashIndex *index)
         begin_used_idx = idx;
 
         if(!empty_slot_count) {
-            memcpy(BUCKET_ADDR(index, compact_tail_idx), BUCKET_ADDR(index, idx), index->bucket_size);
+            /* In case idx==compact_tail_idx, the areas overlap */
+            memmove(BUCKET_ADDR(index, compact_tail_idx), BUCKET_ADDR(index, idx), index->bucket_size);
             idx++;
             compact_tail_idx++;
             continue;