[PATCH] graph: avoid infinite loop in graph_show_commit()

Subsystems: the rest

STALE3737d

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] graph: avoid infinite loop in graph_show_commit()

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 22:54:50

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 <redacted>
---
 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

Re: [PATCH] graph: avoid infinite loop in graph_show_commit()

From: Michal Kiedrowicz <hidden>
Date: 2016-06-15 22:54:51

Nguyễn Thái Ngọc Duy <pclouds <at> gmail.com> writes:
The loop can be triggered with "git diff-tree --graph commit" where
the commit is a non-merge. It goes like this

Isn't this the same issue as in 
http://article.gmane.org/gmane.comp.version-control.git/123979
? (with slightly different fix)

Re: [PATCH] graph: avoid infinite loop in graph_show_commit()

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:54:51

On Sun, Sep 23, 2012 at 6:55 PM, Michal Kiedrowicz
[off-list ref] wrote:
Nguyễn Thái Ngọc Duy <pclouds <at> gmail.com> writes:
quoted
The loop can be triggered with "git diff-tree --graph commit" where
the commit is a non-merge. It goes like this

Isn't this the same issue as in
http://article.gmane.org/gmane.comp.version-control.git/123979
? (with slightly different fix)
I don't know. I'm not familiar enough with graph.c to tell. Maybe Adam
can have a look?

The patch that is cut out is
http://article.gmane.org/gmane.comp.version-control.git/206205
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help