receive-pack: plug memory leak in fast-forward checking code.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
Sep 21, 2006 at 02:07 UTC
9edd7e4652e080a1a3b1ef614d22eba75b39ef87
1 file changed
+7
-6
receive-pack.c
+7
-6
@@ -131,17 +131,18 @@ static int update(struct command *cmd)
131
}
132
if (deny_non_fast_forwards && !is_null_sha1(old_sha1)) {
133
struct commit *old_commit, *new_commit;
134
- struct commit_list *bases;
134
+ struct commit_list *bases, *ent;
135
136
old_commit = (struct commit *)parse_object(old_sha1);
137
new_commit = (struct commit *)parse_object(new_sha1);
138
- for (bases = get_merge_bases(old_commit, new_commit, 1);
139
- bases; bases = bases->next)
140
- if (!hashcmp(old_sha1, bases->item->object.sha1))
138
+ bases = get_merge_bases(old_commit, new_commit, 1);
139
+ for (ent = bases; ent; ent = ent->next)
140
+ if (!hashcmp(old_sha1, ent->item->object.sha1))
141
break;
142
- if (!bases)
142
+ free_commit_list(bases);
143
+ if (!ent)
144
return error("denying non-fast forward;"
144
- " you should pull first");
145
+ " you should pull first");
146
}
147
safe_create_leading_directories(lock_name);
148