Browse Source

Merge pull request #2670 from enkore/f/fcs-playnice

cache sync: don't do memcpy(..., 0, 0)
enkore 8 years ago
parent
commit
6ce7b9505c
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/borg/cache_sync/cache_sync.c

+ 4 - 2
src/borg/cache_sync/cache_sync.c

@@ -87,8 +87,10 @@ cache_sync_feed(CacheSyncCtx *ctx, void *data, uint32_t length)
                 ctx->ctx.user.last_error = "cache_sync_feed: unable to allocate buffer";
                 return 0;
             }
-            memcpy(new_buf, ctx->buf + ctx->head, ctx->tail - ctx->head);
-            free(ctx->buf);
+            if(ctx->buf) {
+                memcpy(new_buf, ctx->buf + ctx->head, ctx->tail - ctx->head);
+                free(ctx->buf);
+            }
             ctx->buf = new_buf;
             ctx->tail -= ctx->head;
             ctx->head = 0;