In normal branch, we should free(file->slices) directly. In error branch, we should check it first in case of slices not allocated.
Signed-off-by: Ruoyu <lian...@ucweb.com> --- dog/farm/slice.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dog/farm/slice.c b/dog/farm/slice.c index 77db771..490a982 100644 --- a/dog/farm/slice.c +++ b/dog/farm/slice.c @@ -102,10 +102,15 @@ void *slice_read(const unsigned char *sha1, size_t *outsize) object = xmalloc(*outsize); strbuf_copyout(&buf, object, *outsize); + free(file->slices); free(file); strbuf_release(&buf); return object; err: + if (file->slices) { + free(file->slices); + file->slices = NULL; + } free(file); strbuf_release(&buf); return NULL; -- 1.8.3.2 -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog