Skip to content

Commit f3ec549

Browse files
Martin Koeglergitster
authored andcommitted
fetch-pack: check parse_commit/object results
Signed-off-by: Martin Koegler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2d3539e commit f3ec549

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

builtin-fetch-pack.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ static void rev_list_push(struct commit *commit, int mark)
4141
commit->object.flags |= mark;
4242

4343
if (!(commit->object.parsed))
44-
parse_commit(commit);
44+
if (parse_commit(commit))
45+
return;
4546

4647
insert_by_date(commit, &rev_list);
4748

@@ -83,7 +84,8 @@ static void mark_common(struct commit *commit,
8384
if (!ancestors_only && !(o->flags & POPPED))
8485
non_common_revs--;
8586
if (!o->parsed && !dont_parse)
86-
parse_commit(commit);
87+
if (parse_commit(commit))
88+
return;
8789

8890
for (parents = commit->parents;
8991
parents;
@@ -103,20 +105,20 @@ static const unsigned char* get_rev(void)
103105

104106
while (commit == NULL) {
105107
unsigned int mark;
106-
struct commit_list* parents;
108+
struct commit_list *parents = NULL;
107109

108110
if (rev_list == NULL || non_common_revs == 0)
109111
return NULL;
110112

111113
commit = rev_list->item;
112114
if (!(commit->object.parsed))
113-
parse_commit(commit);
115+
if (!parse_commit(commit))
116+
parents = commit->parents;
117+
114118
commit->object.flags |= POPPED;
115119
if (!(commit->object.flags & COMMON))
116120
non_common_revs--;
117121

118-
parents = commit->parents;
119-
120122
if (commit->object.flags & COMMON) {
121123
/* do not send "have", and ignore ancestors */
122124
commit = NULL;
@@ -212,7 +214,8 @@ static int find_common(int fd[2], unsigned char *result_sha1,
212214
if (!lookup_object(sha1))
213215
die("object not found: %s", line);
214216
/* make sure that it is parsed as shallow */
215-
parse_object(sha1);
217+
if (!parse_object(sha1))
218+
die("error in object: %s", line);
216219
if (unregister_shallow(sha1))
217220
die("no shallow found: %s", line);
218221
continue;

0 commit comments

Comments
 (0)