Skip to content

git_treebuilder_write_with_buffer refactorings#4182

Merged
ethomson merged 3 commits intolibgit2:masterfrom
pks-t:pks/treebuilder
Mar 28, 2017
Merged

git_treebuilder_write_with_buffer refactorings#4182
ethomson merged 3 commits intolibgit2:masterfrom
pks-t:pks/treebuilder

Conversation

@pks-t
Copy link
Member

@pks-t pks-t commented Mar 28, 2017

Some small refactorings and memory leak fixes for the git_treebuilder_write_with_buffer function. This was triggered by #4181, but does not actually fix the issue.

pks-t added 3 commits March 28, 2017 08:39
While we detect errors in `git_treebuilder_write_with_buffer`, we just
exit directly instead of freeing allocated memory. Fix this by
remembering error codes and skipping forward to the function's cleanup
code.
The `git_tree_entry *entry` variable is defined twice inside of this
function. While this is not a problem currently, remove the shadowing
variable to avoid future confusion.
While writing the tree inside of a buffer, we check whether the buffer
runs out of memory after each tree entry. While we set the error code as
soon as we detect the OOM situation, we happily proceed iterating over
the entries. This is not useful at all, as we will try to write into the
buffer repeatedly, which cannot work.

Fix this by exiting as soon as we are OOM.
@ethomson ethomson merged commit caf7a7a into libgit2:master Mar 28, 2017
@pks-t pks-t deleted the pks/treebuilder branch April 7, 2017 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants