Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-03-03 07:46:21 +0400
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-04-12 22:25:24 +0400
commit081d229106faae3c37c08940fd510a3511bfbd59 (patch)
tree44f7f7111e7433f7a099bedd5ffaf9aab960ea12 /src/revwalk.c
parent1de77cd31432a1bdff060181c6d9ec25a412a0c2 (diff)
revwalk: don't assume malloc succeeds
Diffstat (limited to 'src/revwalk.c')
-rw-r--r--src/revwalk.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index 997771f08..ffa0be6f8 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -58,6 +58,9 @@ struct git_revwalk {
static commit_list *commit_list_insert(commit_object *item, commit_list **list_p)
{
commit_list *new_list = git__malloc(sizeof(commit_list));
+ if (new_list == NULL)
+ return NULL;
+
new_list->item = item;
new_list->next = *list_p;
*list_p = new_list;
@@ -490,7 +493,8 @@ static int revwalk_next_toposort(commit_object **object_out, git_revwalk *walk)
if (--parent->in_degree == 0 && parent->topo_delay) {
parent->topo_delay = 0;
- commit_list_insert(parent, &walk->iterator_topo);
+ if (commit_list_insert(parent, &walk->iterator_topo) == NULL)
+ return GIT_ENOMEM;
}
}
@@ -520,7 +524,8 @@ static int prepare_walk(git_revwalk *walk)
parent->in_degree++;
}
- commit_list_insert(next, &walk->iterator_topo);
+ if (commit_list_insert(next, &walk->iterator_topo) == NULL)
+ return GIT_ENOMEM;
}
if (error != GIT_EREVWALKOVER)
@@ -532,7 +537,8 @@ static int prepare_walk(git_revwalk *walk)
if (walk->sorting & GIT_SORT_REVERSE) {
while ((error = walk->get_next(&next, walk)) == GIT_SUCCESS)
- commit_list_insert(next, &walk->iterator_reverse);
+ if (commit_list_insert(next, &walk->iterator_reverse) == NULL)
+ return GIT_ENOMEM;
if (error != GIT_EREVWALKOVER)
return git__rethrow(error, "Failed to prepare revision walk");