Commit 5767055949fa7c49469611a514c2f4e3ae77c5e1

Stefan Sperling 2018-12-23T14:13:45

prevent crash in error path via tog's stop_blame()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/tog/tog.c b/tog/tog.c
index 90bfd89..e2ca7c7 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -2453,10 +2453,12 @@ stop_blame(struct tog_blame *blame)
 		fclose(blame->f);
 		blame->f = NULL;
 	}
-	for (i = 0; i < blame->nlines; i++)
-		free(blame->lines[i].id);
-	free(blame->lines);
-	blame->lines = NULL;
+	if (blame->lines) {
+		for (i = 0; i < blame->nlines; i++)
+			free(blame->lines[i].id);
+		free(blame->lines);
+		blame->lines = NULL;
+	}
 	free(blame->cb_args.commit_id);
 	blame->cb_args.commit_id = NULL;