diff options
| author | Etienne Samson <samson.etienne@gmail.com> | 2019-12-08 15:25:52 +0100 |
|---|---|---|
| committer | Etienne Samson <samson.etienne@gmail.com> | 2019-12-13 12:01:10 +0100 |
| commit | 97b8491b01e99790a9f643a9571baf65fe168ba8 (patch) | |
| tree | 20909fe04fa4eca5137c98fd06d80c026b94e896 /include/git2/branch.h | |
| parent | 39f78b0c03ccaffd5c4aae97897b616634cae3cf (diff) | |
| download | libgit2-97b8491b01e99790a9f643a9571baf65fe168ba8.tar.gz | |
refs: rename git_reference__set_name to git_reference__realloc
As git_reference__name will reallocate storage to account for longer
names (it's actually allocator-dependent), it will cause all existing
pointers to the old object to become dangling, as they now point to
freed memory.
Fix the issue by renaming to a more descriptive name, and pass a pointer
to the actual reference that can safely be invalidated if the realloc
succeeds.
Diffstat (limited to 'include/git2/branch.h')
| -rw-r--r-- | include/git2/branch.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/git2/branch.h b/include/git2/branch.h index de1d1621b..68fe402ed 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -126,6 +126,12 @@ GIT_EXTERN(void) git_branch_iterator_free(git_branch_iterator *iter); * The new branch name will be checked for validity. * See `git_tag_create()` for rules about valid names. * + * Note that if the move succeeds, the old reference object will not + + be valid anymore, and should be freed immediately by the user using + + `git_reference_free()`. + * + * @param out New reference object for the updated name. + * * @param branch Current underlying reference of the branch. * * @param new_branch_name Target name of the branch once the move |
