diff --git a/CHANGELOG.md b/CHANGELOG.md index 1097803f1..c3ba6b6d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## [0.11.9](https://github.com/nodegit/nodegit/releases/tag/v0.11.9) (2016-03-09) + +[Full Changelog](https://github.com/nodegit/nodegit/compare/v0.11.8...v0.11.9) + +- Fixed crash when calculating diff via `ConvenientPatch` [PR #945](https://github.com/nodegit/nodegit/pull/945) + ## [0.11.8](https://github.com/nodegit/nodegit/releases/tag/v0.11.8) (2016-03-07) [Full Changelog](https://github.com/nodegit/nodegit/compare/v0.11.7...v0.11.8) diff --git a/README.md b/README.md index 96d37f420..d743134d5 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ NodeGit -**Stable: 0.11.8** +**Stable: 0.11.9** ## Have a problem? Come chat with us! ## diff --git a/generate/templates/manual/src/convenient_patch.cc b/generate/templates/manual/src/convenient_patch.cc index a65649cbd..8638cf0d7 100644 --- a/generate/templates/manual/src/convenient_patch.cc +++ b/generate/templates/manual/src/convenient_patch.cc @@ -56,8 +56,12 @@ PatchData *createFromRaw(git_patch *raw) { for (unsigned int i = 0; i < patch->numHunks; ++i) { HunkData *hunkData = new HunkData; - const git_diff_hunk *hunk; - git_patch_get_hunk(&hunk, &hunkData->numLines, raw, i); + const git_diff_hunk *hunk = NULL; + int result = git_patch_get_hunk(&hunk, &hunkData->numLines, raw, i); + if (result != 0) { + continue; + } + hunkData->hunk.old_start = hunk->old_start; hunkData->hunk.old_lines = hunk->old_lines; hunkData->hunk.new_start = hunk->new_start; @@ -72,17 +76,19 @@ PatchData *createFromRaw(git_patch *raw) { bool EOFFlag = false; for (unsigned int j = 0; j < hunkData->numLines; ++j) { git_diff_line *storeLine = (git_diff_line *)malloc(sizeof(git_diff_line)); - const git_diff_line *line; - git_patch_get_line_in_hunk(&line, raw, i, j); + const git_diff_line *line = NULL; + int result = git_patch_get_line_in_hunk(&line, raw, i, j); + if (result != 0) { + continue; + } if (j == 0) { - // calculate strlen only once for the first line of the first hunk. - int calculatedContentLength = strlen(line->content); + int calculatedContentLength = line->content_len; if ( calculatedContentLength > noNewlineStringLength && - !strcmp( + !strncmp( &line->content[calculatedContentLength - noNewlineStringLength], - "\n\\ No newline at end of file\n" + "\n\\ No newline at end of file\n", (std::min)(calculatedContentLength, noNewlineStringLength) )) { EOFFlag = true; } diff --git a/package.json b/package.json index 18868d6ab..03a750a6d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegit", "description": "Node.js libgit2 asynchronous native bindings", - "version": "0.11.8", + "version": "0.11.9", "homepage": "http://nodegit.org", "keywords": [ "libgit2",