git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] graph: avoid infinite loop in graph_show_commit()
@ 2012-09-22 14:24 Nguyễn Thái Ngọc Duy
  2012-09-23 11:55 ` Michal Kiedrowicz
  0 siblings, 1 reply; 5+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-09-22 14:24 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy

The loop can be triggered with "git diff-tree --graph commit" where
the commit is a non-merge. It goes like this

 - graph_show_commit
 - graph_next_line
 - graph_output_padding_line

The last function quits because graph->commit is NULL, but
graph_next_line() does not return "shown", so the loop in
graph_show_commit keeps going.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Corner case. Nobody sane would do that. But still worth plugging.

 graph.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/graph.c b/graph.c
index e864fe2..1735b26 100644
--- a/graph.c
+++ b/graph.c
@@ -1224,7 +1224,7 @@ void graph_show_commit(struct git_graph *graph)
 	struct strbuf msgbuf = STRBUF_INIT;
 	int shown_commit_line = 0;
 
-	if (!graph)
+	if (!graph || !graph->commit)
 		return;
 
 	while (!shown_commit_line) {
-- 
1.7.12.1.389.gc2218b5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-25 18:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-22 14:24 [PATCH] graph: avoid infinite loop in graph_show_commit() Nguyễn Thái Ngọc Duy
2012-09-23 11:55 ` Michal Kiedrowicz
2012-09-23 12:14   ` Nguyen Thai Ngoc Duy
2012-09-24 23:36     ` Junio C Hamano
2012-09-25 18:11       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).