diff --git a/src/blame.c b/src/blame.c index 80b8208..b238f05 100644 --- a/src/blame.c +++ b/src/blame.c @@ -69,14 +69,20 @@ wrap_blame_hunk(const git_blame_hunk *hunk, Blame *blame) py_hunk->lines_in_hunk = hunk->lines_in_hunk; py_hunk->final_commit_id = git_oid_allocfmt(&hunk->final_commit_id); py_hunk->final_start_line_number = hunk->final_start_line_number; - py_hunk->final_signature = hunk->final_signature != NULL ? - git_signature_dup(hunk->final_signature) : NULL; + + py_hunk->final_signature = NULL; + if (hunk->final_signature) + git_signature_dup(&py_hunk->final_signature, hunk->final_signature); + py_hunk->orig_commit_id = git_oid_allocfmt(&hunk->orig_commit_id); py_hunk->orig_path = hunk->orig_path != NULL ? strdup(hunk->orig_path) : NULL; py_hunk->orig_start_line_number = hunk->orig_start_line_number; - py_hunk->orig_signature = hunk->orig_signature != NULL ? - git_signature_dup(hunk->orig_signature) : NULL; + + py_hunk->orig_signature = NULL; + if (hunk->orig_signature) + git_signature_dup(&py_hunk->orig_signature, hunk->orig_signature); + py_hunk->boundary = hunk->boundary; } diff --git a/src/reference.c b/src/reference.c index e597e35..1c78d41 100644 --- a/src/reference.c +++ b/src/reference.c @@ -62,8 +62,7 @@ RefLogIter_iternext(RefLogIter *self) py_entry->oid_old = git_oid_allocfmt(git_reflog_entry_id_old(entry)); py_entry->oid_new = git_oid_allocfmt(git_reflog_entry_id_new(entry)); py_entry->message = strdup(git_reflog_entry_message(entry)); - py_entry->signature = git_signature_dup( - git_reflog_entry_committer(entry)); + git_signature_dup(&py_entry->signature, git_reflog_entry_committer(entry)); ++(self->i); diff --git a/src/tree.c b/src/tree.c index d1968fa..b72d578 100644 --- a/src/tree.c +++ b/src/tree.c @@ -284,20 +284,20 @@ TreeEntry * Tree_getitem_by_index(Tree *self, PyObject *py_index) { int index; - const git_tree_entry *entry; + const git_tree_entry *entry_src; + git_tree_entry *entry; index = Tree_fix_index(self, py_index); if (PyErr_Occurred()) return NULL; - entry = git_tree_entry_byindex(self->tree, index); - if (!entry) { + entry_src = git_tree_entry_byindex(self->tree, index); + if (!entry_src) { PyErr_SetObject(PyExc_IndexError, py_index); return NULL; } - entry = git_tree_entry_dup(entry); - if (entry == NULL) { + if (git_tree_entry_dup(&entry, entry_src) < 0) { PyErr_SetNone(PyExc_MemoryError); return NULL; } @@ -550,16 +550,16 @@ TreeIter_dealloc(TreeIter *self) TreeEntry * TreeIter_iternext(TreeIter *self) { - const git_tree_entry *entry; + const git_tree_entry *entry_src; + git_tree_entry *entry; - entry = git_tree_entry_byindex(self->owner->tree, self->i); - if (!entry) + entry_src = git_tree_entry_byindex(self->owner->tree, self->i); + if (!entry_src) return NULL; self->i += 1; - entry = git_tree_entry_dup(entry); - if (entry == NULL) { + if (git_tree_entry_dup(&entry, entry_src) < 0) { PyErr_SetNone(PyExc_MemoryError); return NULL; } diff --git a/src/treebuilder.c b/src/treebuilder.c index 8354b1b..5957040 100644 --- a/src/treebuilder.c +++ b/src/treebuilder.c @@ -105,19 +105,19 @@ PyObject * TreeBuilder_get(TreeBuilder *self, PyObject *py_filename) { char *filename; - const git_tree_entry *entry; + const git_tree_entry *entry_src; + git_tree_entry *entry; filename = py_path_to_c_str(py_filename); if (filename == NULL) return NULL; - entry = git_treebuilder_get(self->bld, filename); + entry_src = git_treebuilder_get(self->bld, filename); free(filename); - if (entry == NULL) + if (entry_src == NULL) Py_RETURN_NONE; - entry = git_tree_entry_dup(entry); - if (entry == NULL) { + if (git_tree_entry_dup(&entry, entry_src) < 0) { PyErr_SetNone(PyExc_MemoryError); return NULL; }