diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2017-12-16 21:49:45 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-16 21:49:45 +0000 |
| commit | fa8cf14f2ec888bf56e9bed58499736eac8ae040 (patch) | |
| tree | 63e0b0087f633a047dccd0760c05cebd2ae5fbaf /src | |
| parent | 2482559dab65e9d587aa710bee70f72742995fae (diff) | |
| parent | 2388a9e2ab0516c2a9146a1c4d15ced3052fef4c (diff) | |
| download | libgit2-fa8cf14f2ec888bf56e9bed58499736eac8ae040.tar.gz | |
Merge pull request #4447 from pks-t/pks/diff-file-contents-refcount-blob
diff_file: properly refcount blobs when initializing file contents
Diffstat (limited to 'src')
| -rw-r--r-- | src/diff_file.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/diff_file.c b/src/diff_file.c index 270d59bbb..0813315f5 100644 --- a/src/diff_file.c +++ b/src/diff_file.c @@ -139,7 +139,6 @@ int git_diff_file_content__init_from_src( memset(fc, 0, sizeof(*fc)); fc->repo = repo; fc->file = as_file; - fc->blob = src->blob; if (!src->blob && !src->buf) { fc->flags |= GIT_DIFF_FLAG__NO_DATA; @@ -149,12 +148,15 @@ int git_diff_file_content__init_from_src( fc->file->mode = GIT_FILEMODE_BLOB; if (src->blob) { + git_blob_dup((git_blob **)&fc->blob, (git_blob *) src->blob); fc->file->size = git_blob_rawsize(src->blob); git_oid_cpy(&fc->file->id, git_blob_id(src->blob)); fc->file->id_abbrev = GIT_OID_HEXSZ; fc->map.len = (size_t)fc->file->size; fc->map.data = (char *)git_blob_rawcontent(src->blob); + + fc->flags |= GIT_DIFF_FLAG__FREE_BLOB; } else { fc->file->size = src->buflen; git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJ_BLOB); |
